gpt4 book ai didi

objective-c - 数组内数组项替换

转载 作者:行者123 更新时间:2023-11-29 04:52:02 26 4
gpt4 key购买 nike

我有一个数组列表,其中的每个元素都是数组。我知道,这有点奇怪,但这是必要的。所以,我需要替换最深数组的元素。我试过这个:

for (int i = 0; i < [myArray count]; i++) {
for (int j = 0; j < [[myArray objectAtIndex:i] count]; j++) {
for (int k = 0; k < [[[myArray objectAtIndex:i] objectAtIndex:j] count]; k++) {
[[[myArray objectAtIndex:i] objectAtIndex:j] replaceObjectAtIndex:k withObject:@"Some_string"];
}
}
}

出现错误 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance .但我可以记录这个元素,例如NSLog(@"%@", [NSString stringWithFormat:@"%@",[[[myArray objectAtIndex:0] objectAtIndex:0]objectAtIndex:0]]); ,没关系。

它可能是什么?感谢您的帮助。

最佳答案

您的数组实例是 NSMutableArray 而不是不可变的 NSArray 吗?

关于objective-c - 数组内数组项替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8646405/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com