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
Post a Comment