我有两个多维 NSMutableArray
。每个在主 NSMutableArray
中都有四个 NSMutableArray
。我想将第一个数组中的一个位置的数据与第二个数组中的数据交换,并且我正在努力解决 replaceObjectatIndex: withObject:
的语法。这是我的代码行:
[newStock replaceObjectAtIndex:0 objectAtIndex:0 withObject: [[oldStock objectAtIndex: 0] objectAtIndex: 0]];
我试图将 oldStock
数组中的数据放入 newStock
数组中,但收到错误消息:“'NSMutableArray 没有可见的 @interface” '声明选择器'replaceObjectAtIndex:'”。我已经使用非多维数组完成了此操作,因此我相信选择器是有效的。
最佳答案
Objective-C 中的旧语法如下:
[[newStock objectAtIndex:0] replaceObjectAtIndex:0 withObject: [[oldStock objectAtIndex: 0] objectAtIndex: 0]];
幸运的是,您现在可以使用新语法:
newStock[0][0] = oldStock[0][0];
关于objective-c - NSMutableArray 没有可见接口(interface)声明选择器 ReplaceObjectAtIndex :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34457530/