iOS Copy

来源:互联网 发布:神盾网络验证破解 编辑:程序博客网 时间:2024/05/22 07:56


//遵守Copying, MutableCopying协议@interface Person : NSObject <NSCopying, NSMutableCopying>@property (nonatomic, copy) NSString *name;@end@implementation Person//实现方法- (id)copyWithZone:(NSZone *)zone{    Person *p = [[[self class] allocWithZone:zone] init];        p.name = self.name;        return p;}- (id)mutableCopyWithZone:(NSZone *)zone{    Person *p = [[[self class] allocWithZone:zone] init];        p.name = self.name;        return p;}@end





0 0
原创粉丝点击