现在的位置: 首页 > 综合 > 正文

对象的深拷贝

2018年02月02日 ⁄ 综合 ⁄ 共 286字 ⁄ 字号 评论关闭
@interface zzTest : NSObject
-(id)copywithzone:(NSZone*)zone;
@property (strong) NSString *name;
@property (strong) NSString *year;
@end

@implementation zzTest
-(id)copywithzone:(NSZone*)zone
{
    zzTest *test= [[[self class] allocWithZone:zone] init];
    test.name = [_name copy];
    test.year = [_year copy];
    return test;
}
@end

抱歉!评论已关闭.