My code is something like this:
[request setPostValue:employee.empId forKey:@"empId"];
where employee is a "POCO" object that has a property empId which is int, but the method is waiting an identifier.
I've tried already sending setPostValue:&employee.empId and setPostValue:[employee.empId] but still getting errors.
Can I get the (id) in any way? or must I create another object from the property?
Yeah, you need to create another object from the integer before you can hand it off to a method that’s expecting an id
.
[request setPostValue:[NSNumber numberWithInt:employee.empId] forKey:@"empId"];
Alternatively, with more recent versions of the SDK (post-iOS 6, I think?), you can use Objective-C’s new boxing literals:
[request setPostValue:@(employee.empId) forKey:@"empId"];
[request setPostValue:[NSNumber numberWithInt:employee.empId] forKey:@"empId"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With