"Incompatible types in initialisation" error makes no sense
I have开发者_StackOverflow中文版 been a Java programmer for years but only iPhone/Obj-c for a few months. Every time I think I'm comfortable with the language something weird happens. Why does the following generate a "Incompatible types in initialisation" compile error? It seems so straight forward. 'double' is a primitive right?!?
-(void) testCalling{
double myDoub = [self functionReturningDouble:3.0];
}
-(double) functionReturningDouble:(double) input{
return 1.0;
}
Try to swap the method declarations. It may be a scope problem as Georg notices:
-(double) functionReturningDouble:(double) input{
return 1.0;
}
-(void) testCalling{
double myDoub = [self functionReturningDouble:3.0];
}
In Objective-C (and this is valid for C), a method does "exists" only if it has been defined or declared before.
精彩评论