我正在尝试构建一个嵌套数组:首先,我创建一个“PlayerItems”数组,该数组将包含 10 个数组,每个数组都包含项目对象,对应于游戏中每个玩家的库存。在指示的行上,我收到以下错误:
错误:无效值没有被忽略,因为它应该是
这里的 void 值是多少?如果我[[PlayerItems objectAtIndex:i] addObject:myitem]
改用,程序会编译但会崩溃。如果我将该行注释掉,它会编译并运行正常。感谢您的帮助!
self.PlayerItems = [[NSMutableArray alloc] initWithCapacity:11];
NSMutableArray *itemarray = [[NSMutableArray alloc] initWithCapacity:60];
item *myitem = [[item alloc] init];
item.kind = 1;
for (int i = 1; i < 10; i++) {
itemarray = [[NSMutableArray alloc] initWithCapacity:60];
[PlayerItems addObject:itemarray];
for (int i2 = 1; i2 < 50; i2++) {
myitem = [[item alloc] init];
myitem.kind = 1;
// The error occurs on the line below:
((NSMutableArray *) [[PlayerItems objectAtIndex:i] addObject:myitem]);
}
}