ios - Why am I getting a "Unable to parse NSPredicate" error -


i built following predicate use magicalrecord against core data store.

//  format date correctly nsdateformatter *dateformat = [[nsdateformatter alloc]init]; [dateformat setdateformat:@"yyyy-mm-dd*"];  //  hh:mm nsstring *formatteddate = [dateformat stringfromdate:currentlyselecteddate];  nsstring *stringpredicate = [nsmutablestring stringwithformat:                              @"aposx >= %f , aposx < %f , %f > aposy , %f <= (aposy + aposh) , astarttime %@",                              [staffindex floatvalue], [staffindex floatvalue] + 218, touchpoint.y, touchpoint.y, formatteddate];  nspredicate *predicate =  ([nspredicate predicatewithformat: stringpredicate]); 

it crashes on last statement, error:

* terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'unable parse format string "aposx >= 218.000000 , aposx < 436.000000 , 15.000000 > aposy , 15.000000 <= (aposy + aposh) , astarttime 2013-05-09*"'

i have tried know of, searched google , so, , still don't understand why it's failing... can please enlighten me?

don't create format string, use predicate format creation method:

predicatewithformat: 

this allows predicate process format parameters sees fit (adding quotes required).

for date, need modify predicate use range. can't directly check day of date , ignore time need say:

date > startofday , date < endofday 

where startofday , endofday nsdate instances (probably created using nsdatecomponents).


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -