对数组中的数组使用"replaceObjectAtIndex"

Jer*_*emy 5 iphone replace object multidimensional-array

我在(可变)数组中有一个数组.我试图用"replaceObjectAtIndex"替换某些对象.

我试过了:

[[mutableArrayName objectAtIndex:0]replaceObjectAtIndex:0 withObject:@"TEST"]; 
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

- [__ 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"];
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:

*由于未捕获的异常'NSRangeException'终止应用程序,原因:'* - [NSMutableArray replaceObjectAtIndex:withObject:]:索引16660超出边界[0 .. 0]'

Kay*_*Kay 5

第二种方法依赖于3个阵列而不是2.第一种方法似乎没问题,但我猜你有一个NSArray内部NSMutableArray因为NSArray:replaceObjectAtIndex:withObject不存在.因此,请确保所有数组都是可变的.