fhongchan 2015-10-12 11:57 采纳率: 73.3%
浏览 1718

iOS遵循NSCopying协议采用的copy 和自己写的myCopy函数有什么区别?

-(id)copyWithZone:(NSZone *)zone
{
Student * stu = [[Student allocWithZone:zone] init];
stu.name = self.name;
stu.age = self.age;
return stu;
}

-(id) myCopy
{
Student *stu = [Student new];
stu.name =self.name;
stu.age = self.age;
return stu;
}

  • 写回答

2条回答 默认 最新

  • devmiao 2015-10-12 16:05
    关注
    评论

报告相同问题?