我想允许对我的类对象进行深层复制并尝试实现 copyWithZone 但调用会[super copyWithZone:zone]
产生错误:
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
我应该如何创建此类的深层副本?