NSMutableArray 的可见接口声明了选择器 replaceObjectAtIndex:
No visible interface for NSMutableArray declares the selector replaceObjectAtIndex:
我有两个多维 NSMutableArray
。每个在主 NSMutableArray
中有四个 NSMutableArray
。我想将第一个数组中一个位置的数据与第二个数组中的数据交换,我正在为 replaceObjectatIndex: withObject:
的语法苦苦挣扎。这是我的代码行:
[newStock replaceObjectAtIndex:0 objectAtIndex:0 withObject: [[oldStock objectAtIndex: 0] objectAtIndex: 0]];
我试图将 oldStock
数组中的数据放入 newStock
数组中,但收到错误消息:"No visible @interface for 'NSMutableArray' declares the selector 'replaceObjectAtIndex:'"。我已经使用非多维数组完成了此操作,因此我相信选择器是有效的。
Objective-C 中的旧语法是这样的:
[[newStock objectAtIndex:0] replaceObjectAtIndex:0 withObject: [[oldStock objectAtIndex: 0] objectAtIndex: 0]];
幸运的是,您现在可以使用新语法了:
newStock[0][0] = oldStock[0][0];
我有两个多维 NSMutableArray
。每个在主 NSMutableArray
中有四个 NSMutableArray
。我想将第一个数组中一个位置的数据与第二个数组中的数据交换,我正在为 replaceObjectatIndex: withObject:
的语法苦苦挣扎。这是我的代码行:
[newStock replaceObjectAtIndex:0 objectAtIndex:0 withObject: [[oldStock objectAtIndex: 0] objectAtIndex: 0]];
我试图将 oldStock
数组中的数据放入 newStock
数组中,但收到错误消息:"No visible @interface for 'NSMutableArray' declares the selector 'replaceObjectAtIndex:'"。我已经使用非多维数组完成了此操作,因此我相信选择器是有效的。
Objective-C 中的旧语法是这样的:
[[newStock objectAtIndex:0] replaceObjectAtIndex:0 withObject: [[oldStock objectAtIndex: 0] objectAtIndex: 0]];
幸运的是,您现在可以使用新语法了:
newStock[0][0] = oldStock[0][0];