【发布时间】:2015-08-10 07:58:20
【问题描述】:
我想允许对我的类对象进行深度复制,并尝试实现 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
我应该如何创建这个类的深层副本?
【问题讨论】:
标签: ios copywithzone