4
我希望让我的类对象的深拷贝和想实现copyWithZone但调用[super copyWithZone:zone]
产生了错误:错误:“NSObject的”不可见@interface声明选择“copyWithZone:”
error: no visible @interface for 'NSObject' declares the selector 'copyWithZone:'
@interface MyCustomClass : NSObject
@end
@implementation MyCustomClass
- (id)copyWithZone:(NSZone *)zone
{
// The following produces an error
MyCustomClass *result = [super copyWithZone:zone];
// copying data
return result;
}
@end
我应该如何创建此类的深层副本?
这是正确的。我写了一个类似的答案,但他打我:) – Kibitz503
你的答案完全忽略了区域。请参阅http://stackoverflow.com/questions/9907154/ –
@RogerBinns请参阅接受的答案http://stackoverflow.com/questions/4631526/iphone-idcopywithzonenszone-zone-what-is-zone-for?rq=1 – rmaddy