Strange Build Errors in XCode
I have this method declaration in an interface:
#import "LotPolygon.h"
...
@interface LotLattice : NSObject {
... //member variables
}
- (LotPolygon *) lotPolygonContainingCoordinate:(CLLocationCoordinate2D)coord;
...
@end
The compiler gives this error for the method declaration:
Expected ')' before LotPolygon.
If I comment it out, the code builds with the warning you'd expect (Lotlattice may not respond...) and functions and that method works just as it's supposed to. But that warning really bothers me because it makes it less likely that I'll see other warnings that I need to see. I'd really like it to compile with the proper declaration, and I just 开发者_如何学Gocan't see anything wrong with that line.
I've even tried moving that line around in the file to see if it was really a line right before it that was pissing off Xcode, but no--It really doesn't like that line. Any ideas?
That error means that the compiler doesn't know about the LotPolygon
class. Either include the header file that defines that class, or add a forward declaration:
// This says that LotPolygon is the name of a class, but it doesn't define
// anything else about it
@class LotPolygon;
- (LotPolygon *) lotPolygonContainingCoordinate:(CLLocationCoordinate2D)coord;
XCode usually print that error when it couldn't find LotPolygon declaration. Make sure it can find the @interface and the @implementation of that object
精彩评论