ios - desired type NSNumber given type __NSCFString error -


i'm getting core data error can't figure out how fix.

i pulling out data of object dictionary, showing data form, , fields allow editing, trying store data object on submission.

however, on setting new/updated values error

unacceptable type of value attribute: property = "totallocations"; desired type = nsnumber; given type = __nscfstring; value = 7.

here code handles particular property...

    //grab value property      if (myobject.totallocations)     [data setobject:myobject.totallocations forkey:@"totallocations"];      // store object     _myobject.totallocations = [data objectforkey:@"totallocations"]; 

aside these 2 lines there isn't usage of property. can modified, not user on particular screen

is type of totallocations in core data entity integer , myobject.totallocations nsstring? if yes should set core data this:

[data setvalue:[nsnumber numberwithinteger:[myobject.totallocations integervalue]] forkey:@"totallocations"]; 

the way set managed objects this:

- (void)insertnewpromo:(nsdictionary *)promojson {   nsmanagedobjectcontext *context = [self.promofetchedresultscontroller managedobjectcontext];   nsentitydescription *entity = [[self.promofetchedresultscontroller fetchrequest] entity];   nsmanagedobject *newmanagedobject = [nsentitydescription insertnewobjectforentityforname:[entity name] inmanagedobjectcontext:context];    // checking if inappropriate data in json avoid crashes.   if ([[promojson objectforkey:@"id"] iskindofclass:[nsnull class]])       [newmanagedobject setvalue:nil forkey:@"id"];   else       [newmanagedobject setvalue:[nsnumber numberwithinteger:[[promojson objectforkey:@"id"] integervalue]] forkey:@"id"];   ...   ...   nserror *error = nil;   if (![context save:&error])   {       if (debug_on == 1)         nslog(@"unresolved error %@, %@", error, [error userinfo]);       abort();   } } 

the id object of promojson nsstring


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -