我在(可变)数组中有一个数组。我正在尝试用“replaceObjectAtIndex”替换某些对象。
我已经尝试过:
[[mutableArrayName objectAtIndex:0]replaceObjectAtIndex:0 withObject:@"TEST"];
但我收到以下错误:
-[__NSArrayI ReplaceObjectAtIndex:withObject:]:无法识别的选择器发送到实例 0x4e24d70 2011-03-17 17:02:07.008 联系方式[5145:207] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[__NSArrayI ReplaceObjectAtIndex:withObject:]:发送了无法识别的选择器到实例 0x4e24d70'
我也尝试过:
[mutableArrayName replaceObjectAtIndex:[[mutableArrayName objectAtIndex:0]objectAtIndex:0] withObject:@"TEST"];
但我收到以下错误:
* 由于未捕获的异常“NSRangeException”而终止应用程序,原因:“* -[NSMutableArray ReplaceObjectAtIndex:withObject:]:索引 16660 超出范围 [0 .. 0]”
最佳答案
第二种方法依赖于拥有 3 个数组而不是 2 个。第一种方法似乎很好,但我猜你在 NSMutableArray
内部有一个 NSArray
因为 NSArray:replaceObjectAtIndex:withObject
不存在。因此请确保所有数组都是可变的。
关于iphone - 对数组内的数组使用 "replaceObjectAtIndex",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5345263/