1

Anyone know why this gives an "Unable to parse the format string" error at runtime?

[wordListArray filterUsingPredicate:[NSPredicate predicateWithFormat:@"pinyin contains[cd] %@ OR pinyin contains[cd] %@ OR BEGINSWITH[cd] %@", [NSString stringWithFormat:@" %@1", searchTerm], [NSString stringWithFormat:@" %@2", searchTerm], searchTerm]];

for some reason i get this when ever i do complex predicates (ie those with OR's on them). i thought nspredicate is supposed to be able to hand this?

ngb
  • 821
  • 9
  • 21
  • 1
    How about this `@"(pinyin contains[cd] %@) OR (pinyin contains[cd] %@) OR (BEGINSWITH[cd] %@)"`? Any change? Also before `BEGINSWITH[cd] %@` are you missing something? – iDev Nov 28 '12 at 06:48
  • 1
    thats it! I've been staring at this for days and re-writing these queries over and over and haven't been able to get it to work until your comment - sometimes the brain doesn't see things.. thank you! – ngb Nov 28 '12 at 08:49
  • Sometimes all you need is an extra pair of eyes to look into that. :) Glad to help. – iDev Nov 28 '12 at 08:51

2 Answers2

2

You are missing some search key word or so before "BEGINSWITH[cd] %@". Add it and check if it is still showing this error. Probably you are looking into something like,

@"(pinyin contains[cd] %@) OR (pinyin contains[cd] %@) OR (pinyin BEGINSWITH[cd] %@)"

iDev
  • 23,310
  • 7
  • 60
  • 85
0

If I remember correctly, AND and OR didn't work for me either, but && and || did.

Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
  • I remember there was a flag i needed to set somewhere to enable the "AND" and "OR" format. I cant find it anymore in the docs in my usual goto places. maybe someone else reading this might be able to fill us in. – ngb Nov 28 '12 at 08:58