There are quite a few features a C function acquires when defined inside of the @implementation
block of an Objective-C class, e.g. it can be accessed before declared:
@implementation TDWClass
- (void)method {
bar(); // the function is accessible here despite not being declared in the code before
}
void bar(void) {
NSLog(@"Test");
}
@end
Plus it is granted access to the private ivars of the class:
@implementation TDWClass {
@private
int _var;
}
- (void)foo {
bar(self);
}
void bar(TDWClass *self) {
self->_var += 2; // a private instance variable accessed
}
@end
Some sources also say that static
variables inside of @implementantion
section had special meaning (unlike C static
they were private to the enclosing class, not the compilation unit), however I could not reproduce this on my end.
Having that said, almost all such features were either deduced or found on third-party sources. I wonder if anything like that is/had ever been documented anywhere, so i can read through full list or special meanings of C statements inside of Objective-C class sections?