复制 NSMutableArray 项
我正在复制这样的可变数组:
//copy players' info into playerList from a dictionary
playerList = [[NSMutableArray alloc] initWithArray:[params objectForKey:@"p"] copyItems:YES];
数组中的项目像这样实现 copyWithZone:
- (id)copyWithZone:(NSZone *)zone
{
PlayerInfo* copy = [[[self class] allocWithZone:zone] init];
[copy setNick:[self nick]];
...
[copy setIsChallengedByMe:[self isChallengedByMe]];
return copy;
}
但是,playerList 似乎只有“超出范围”的对象。我做错了什么?
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:
- (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". What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设你的意思是它们在调试器中出现“超出范围”。不用担心,这很常见,并不一定意味着有问题。如果将数组的描述打印到控制台,它应该可以正常打印所有内容。
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.