I'm trying to parse an integer from a NSDictionary using the code
[activeItem setData_id:[[NSString stringWithFormat:@"%@", [dict valueForKeyPath:@"data_id"]] integerValue]];
However, this is giving me this error: Incompatible integer to pointer conversion sending 'NSInteger' (aka 'int') to parameter of type 'NSInteger *' (aka 'int *')
setData_id takes an integer as a parameter. If I want to parse to a string, [NSString stringWithFormat:@"%@", [dict valueForKeyPath:@"data_id"]]
works perfectly.
What I'm doing here is parsing the result of valueForKeyPath to a String, then parsing an integer from that.
*
and the other doesn't.setData_id:
.*
. You don't want a pointer.stringWithFormat
-- just applyintegerValue
directly to the result fromvalueForKeyPath
.