I know that you can declare a C function outside of a class, but is it possible to declare a Objective-C method outside of a class?
Example:
// Works
void printHelloC()
{
NSLog(@"Hello.");
}
// Error
-(void) printHelloOC
{
NSLog(@"Hello.");
}
int main (int argc, const char * argv[])
{
@autoreleasepool {
printHelloC();
[self printHelloOC];// 'self' obviously would not work but you get the idea
}
return 0;
}
It depends. You can do something similar with method adding at runtime:
But that is about it outside of a @class construct, and it really just covers up what happens with a category.