Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I allowed to write and use methods in an implementation that aren't declared in the header file in Objective-C?

Tags:

objective-c

@interface SomeClass : NSObject
{
}
@end

@implementation SomeClass
-(void) awesomeMethod600
{
}
@end

No error, and awesomeMethod600 works.

like image 495
Halpanger900 Avatar asked Feb 03 '26 06:02

Halpanger900


1 Answers

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.

like image 149
Alex Rozanski Avatar answered Feb 04 '26 20:02

Alex Rozanski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!