实例方法
实例方法是在实例化实例后,在类的特定实例上可用的方法:
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