提问人:Miguel Sanchez Cuarental 提问时间:8/11/2015 最后编辑:rmaddyMiguel Sanchez Cuarental 更新时间:8/11/2015 访问量:40
对象可复制的 objective-c
Object copiable objective-c
问:
在我的应用程序中,我有一个对象,我想在他的属性更改之前复制它。我的应用的类包含以下代码:The class of my app has the following code:
@interface match : NSObject
@property int iMatchId;
-(id) copyWithZone: (NSZone *) zone;
@end
在实现该对象的类中,我在方法“copyWithZone”中有以下代码:
-(id) copyWithZone: (NSZone *) zone
{
match *matchCopy = [[match allocWithZone: zone] init];
matchCopy.iMatchId = _iMatchId;
return matchCopy;
}
当我想复制对象时,我执行以下代码:
_oOldMatch = [_oMatch copy];
但是如果我改变变量,那么它就会改变变量。_oMatch
_oOldMatch
我不知道我是否在做坏事。
答: 暂无答案
评论
i
o
_oMatch
NSMutableArray
int
copy
int
NSCopying