Thursday, May 14, 2009

Cannot use object as a parameter to a method

I was helping someone with a project that was getting a bizarre error message from XCode. The message was Error: Cannot use object as a parameter to a method.

This was some what misleading as the error really referred to what was being returned from the method.

- (NSString)formatPrice:(NSNumber *)priceNumber

The problem was the leading (NSString), which was a typo that should have been (NSString *). Once that change was made, the code compiled and ran correctly.

1 comment:

Unknown said...

Thank you !

Have just spent hours troubleshooting this issue.

Ben