可能重复:
Difference between inheritance and Categories in Objective-c
我什么时候应该使用子类?什么时候应该使用类别?
答案 0 :(得分:0)
当您想要扩展基础使用的功能时的子类。
@interface MyObject: NSObject<SomeProtocol>
如果要为可能无法控制的代码添加便捷方法,请添加类别。
@interface UIView (MyViewAdditions)
- (void)recursiveEnumerateSubviewsUsingBlock:(void (^)(UIView *view, BOOL *stop))block;