例項方法

例項方法是在例項化例項後,在類的特定例項上可用的方法:

MyClass *instance = [MyClass new];
[instance someInstanceMethod];

這是你如何定義一個:

@interface MyClass : NSObject

- (void)someInstanceMethod; // "-" denotes an instance method

@end

@implementation MyClass

- (void)someInstanceMethod {
    NSLog(@"Whose idea was it to have a method called \"someInstanceMethod\"?");
}

@end