简体   繁体   English

复制NSMutableArray项目

[英]copy NSMutableArray item

I am copying a mutable array like this: 我正在复制这样的可变数组:

//copy players' info into playerList from a dictionary
playerList = [[NSMutableArray alloc] initWithArray:[params objectForKey:@"p"] copyItems:YES];

The items in the array implement copyWithZone like this: 数组中的项目实现了copyWithZone,如下所示:

- (id)copyWithZone:(NSZone *)zone
{
   PlayerInfo* copy = [[[self class] allocWithZone:zone] init];
   [copy setNick:[self nick]];
   ...
   [copy setIsChallengedByMe:[self isChallengedByMe]];

   return copy;
}

However, playerList only seems to have objects which are "out of scope". 但是,playerList似乎仅具有“超出范围”的对象。 What am I doing wrong? 我究竟做错了什么?

I assume you mean they appear "out of scope" in the debugger. 我假设您的意思是它们在调试器中显示为“超出范围”。 Don't worry about that, it is quite common and doesn't necessarily mean something is wrong. 不必担心,这很普遍,不一定表示出了问题。 If you print the description of the array to the console, it should print everything fine. 如果将数组的描述打印到控制台,它应该可以正常打印。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM