objective c - Does core data do its own type casting in the background? -


i working on simple comparison of 2 lists see items in "evaluation" list contained in larger "target" list. getting data on-the-fly- parsing 2 csv files , storing strings. import data data store , can list of entities no problem

the problem comes when search. essentially, looking short isbns in form of 1234 evaluation list in target list, in form of 1234-5. predicate using using contains comparison in form of [nsstring stringwithformat:@"%@ contains %@", koc_target_printbookcode, evalisbn]

the error following (grabbed nslog)

nsinvalidargumentexception: can't value (1494) in string (49885); value not string 

i impression though isbn being read nsstring , core data store has data point spec'd string, core data still doing in background value whatever reason sees fit. ideas?


here relevant process logic (though use term dubiously) code. unless otherwise noted in code, values being manipulated and/or stored nsstring:

nsarray *evalbooks = [self getentitiesbyname:koc_entityname_evalbook                               usingpredicatevalue:[nsstring stringwithformat:@"%@ > \"\"", koc_eval_bookcode]                         withsubstitutionvariables:nil                                           inmodel:[self managedobjectmodel]                                       andcontext:[self managedobjectcontext]                                   sortbyattribute:nil];      if ( ( !evalbooks ) || ( [evalbooks count] == 0 ) ) {         // have problem         nslog(@"( !evalbooks ) || ( [evalbooks count] == 0 )");         return;     }      [evalbooks retain];      int firstevalbook = 0;     int thisevalbook = firstevalbook;     int lastevalbook = [evalbooks count]; nslog(@"lastevalbook: %i", lastevalbook);     (thisevalbook = firstevalbook; thisevalbook < lastevalbook; thisevalbook++) {          nsmanagedobject *evalbook = [[evalbooks objectatindex:thisevalbook] retain];          nsstring *rawisbn = [[evalbook valueforkey:koc_eval_bookcode] retain];         nsstring *isbnroot = [[self getisbnrootfromisbn:rawisbn] retain];         // custom method created , use elsewhere without issues.         nsarray *foundbooks = [self getentitiesbyname:koc_entityname_targetbook                                     usingpredicatevalue:[nsstring stringwithformat:@"%@ contains %@", koc_target_printbookcode, isbnroot]                              withsubstitutionvariables:nil                                                 inmodel:[self managedobjectmodel]                                              andcontext:[self managedobjectcontext]                                         sortbyattribute:koc_target_printbookcode];          if ( foundbooks != nil ) {              [foundbooks retain];             nslog(@"foundbooks: %lu", [foundbooks count]);          } else {          } 

if you're building predicate nsstring, believe

[nsstring stringwithformat:@"%@ contains %@", koc_target_printbookcode, isbnroot] 

should be

[nsstring stringwithformat:@"%@ contains '%@'", koc_target_printbookcode, isbnroot] 

it seems you're confusing way predicatewithformat: works way stringwithformat: works.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -