I have a class with a method that works and I have tested it but xcode still raises a warning over t开发者_Go百科he method:
MapPoint *mp = [[MapPoint alloc] initWithCoordinate:[newLocation coordinate]
title:[locationTitleField text]];
no 'initWithCoordinate:title' method found?
As Johannes said, you should declare the method in the header file of the class.
If you are not using the method outside of the class implementation, you can create an anonymous category declaration at the top of your .m file:
@interface MapPoint()
- (id) initWithCoordinate:(MapCoordinate *)coordinate title:(NSString *)title;;
@end
An anonymous category "extends" your existing class with new methods. Since you're declaring it inside your source file (.m) instead of a header file (.h), it will only be visible to code in that source file.
I can't say anything about your concrete case (is MapPoint a framework class?) but you should make sure the method is declared in an imported header file.
If that's the case and the warning still exists, try a full rebuild (clean+build). XCode's a little strange from time to time.
精彩评论