Ist es möglich zu erklären, eine Objective-C-Methode außerhalb einer Klasse?

Ich weiß, dass Sie erklären können, einer C-Funktion außerhalb einer Klasse, aber ist es möglich zu erklären, eine Objective-C-Methode außerhalb einer Klasse?

Beispiel:

//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;
}
InformationsquelleAutor Stas Jaro | 2012-02-02
Schreibe einen Kommentar