分类定义:
@interface Fraction (MathOps)
-(Fraction *) add: (Fraction *) f;
@end
协议定义:
@protocol NSCoping
- (id) copyWithZone: (NSZone *) zone;
@end
@protocol Drawing
-(void) paint;
@required
-(void) erase;
@optional
-(void) outline;
@end
协议使用:
@interface AddressBook:NSObject<NSCoping> |
|