【发布时间】:2011-08-23 23:51:43
【问题描述】:
在 NSObject 协议中声明了保留。
因此 NSObject 类和 NSProxy 类实现它。
然而 NSProxy 和 NSObject 类都有一个 alloc。
为什么NSObject协议中没有声明alloc?
附加问题: NSObject 协议还用于存储方法的类版本,因为实例方法在 NSObject 类中。有什么可以阻止在 NSObject 协议中声明类和实例。为什么要拆分它们?
@protocol NSCopying
- (id)copyWithZone:(NSZone *)zone; //INSTANCE METHOD version of copyWithZone
@end
@interface NSObject <NSObject> {
Class isa;
}
...
+ (id)copyWithZone:(NSZone *)zone; //CLASS METHOD version of copyWithZone
干杯
【问题讨论】:
标签: iphone ios nsobject nsproxy