@interface SomeClass : NSObject
{
}
@end
@implementation SomeClass
-(void) awesomeMethod600
{
}
@end
No error, and awesomeMethod600 works.
@interface SomeClass : NSObject
{
}
@end
@implementation SomeClass
-(void) awesomeMethod600
{
}
@end
No error, and awesomeMethod600 works.
The method declarations in the class interfaces are there for the compiler (to suppress warnings), since method lookup in Objective-C is done at runtime, and not compile time.
Perspx is right.
Try building this in XCode:
@implementation SomeClass
-(void)awesomeMethod {
[self notAwesomeMethod];
}
-(void)notAwesomeMethod {}
@end
You should see a warning that says 'SomeClass' may not respond to '-notAwesomeMethod'. Try inverting the order of the method definitions... no error since notAwesomeMethod
is now already defined, and thus the compiler knows about it. Class interfaces do this upfront.
This is also nice behavior because you can choose to only publicize the class's public interface, and keep any internal private methods out of the .h
file.