I am trying to get rid of some of these warnings from my iPhone application. The one I get the most is when I have a void function and I call it using [self myFunction];. The warning is on the line where I call the function and it says: "Method '-myFunction' not found (return type defaults to 'id')." What do I need to do to fix this? Thanks
Declare the function in your header file, like so:
-(void)myFunction;
or
-(NSString*)myFunction;
-(id)myFunction;
-(NSInteger)myFunction;
-(BOOL)myFunction;
etc etc.
This is of more importance than just silencing the compiler: if the return type of a function is not a pointer (id
or anything*
), especially when it doesn't have the same size, you can get really odd and hard to find bugs.
E.g. if a function returns a CGRect
struct, and the compiler assumes id
(as the warning says), really weird things will happen.
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