ios - Set value for key in case of NSInteger -


i trying set value in core data using setvalue:forkey: throwing error:

(use of undeclared identifier: 'newid'}

when trying save nsinteger. can suggest correct syntax?

 nsinteger newid = lastid+1;  [record setvalue:newid forkey:@"localid"];//error  

got similar error when tried setobject instead of setvalue

nsinteger primitive type, not object. should box nsnumber this:

nsinteger newid = lastid+1;  [record setvalue:@(newid) forkey:@"localid"]; 

and can convert this:

nsinteger recordid = [((nsnumber*)[record valueforkey:@"localid"]) integervalue] 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -