- (void) doSomething: (id)with {
int a;
a = [with doSomething];
}
How does the compiler know what type [with doSomething] is going to return? Does it assume an int, since that’s what I’m assigning to?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It doesn’t know for sure what type is returned, because doSomething could be implemented with a different return type by several different classes.
I believe the compiler looks for all method implementations with that name, and makes sure at least one of them returns an int in the example above. If none of the “doSomething” signatures returned an int, it would give a warning.