The key must have a method in the parent class, which can be overridden in the child class.
@interface Dog : NSObject
- (void) bark;
@end
@implementation Dog
- (void) bark {
NSLog(@"Ruff!");
}
@end
@interface Chihuahua : Dog
@end
@implementation Chihuahua
- (void) bark {
NSLog(@"Yipe! Yipe! Yipe!");
}
@end
, . , :
Dog *someDog = [Chihuahua alloc] init] autorelease];
[someDog bark];
: Yipe! Yipe! Yipe!