What is up.
RSS icon Email icon Home icon
  • objective-c error message: invalid conversion from ‘objc_object*’

    Posted on September 19th, 2007 Alan No comments

    This error message had me stumped for a while:

    invalid conversion from ‘objc_object*’ to ‘int’

    the line in question was something like this:

    int iResult = [MyUtils utilsMemberFunc:param1,param2];

    it doesn’t matter what the "to" type is, what is important is that you recognize that this message, in this context, is reporting that the utilsMemberFunc declaration was not found and due to objective-c’s dynamic binding it is assuming it returns an objc_object* rather than the type that utilsMemberFunc was declared to return.  So why isn’t it finding the declaration?  Because I used ‘,’ rather than ‘:’ to separate the parameters.  Besides the fact my brain still thinks in C++, I use commas to separate parameters in a variable list alot ( [NSString stringWithFormat:@"%d,%d", num1, num2]).

    Through trial and error and comparing similar code that works it finally dawned on me that my syntax was incorrect.

    Leave a reply