符合协议
你可以向标准类添加协议以扩展其功能:
@protocol EncodableToString <NSObject>
- (NSString *)toString;
@end
@interface NSDictionary (XYZExtended) <EncodableToString>
@end
@implementation NSDictionary (XYZExtended)
- (NSString *)toString {
return self.description;
}
@end
XYZ
你的项目的前缀