我想问一下在自定义类(没有父类)中实现copy和mutableCopy这两种方法,应该怎样实现?- person.m
- #import "Person.h"
- @implementation Person
- - (id)copyWithZone:(NSZone *)zone{
-
- Person * p = [[[self class] allocWithZone:zone] init];
- p.age = self.age;
- return p;
- }
- - (id)mutableCopyWithZone:(NSZone *)zone{
-
- Person * p1 = [[self class] allocWithZone:zone];
- p1.age = self.age;
- return p1;
-
- }
复制代码
这是我在网上看的,看起来copy和mutableCopy内部都是一样的代码,很迷惑……求指教
|
|