当 NSMutableArray
中的两个在索引 0 处具有相同值时出现不可预测的错误,然后我想删除该对象并用空字符串替换对象。但是应用程序崩溃说
-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0xe2a06b0
2012-03-22 14:36:48.181 golf eScorer[3849:11f03] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]:
unrecognized selector sent to instance 0xe2a06b0'
当我使用断点调试而不是日志显示时
2012-03-22 14:36:44.548 golf eScorer[3849:11f03] ArrayOfGameidOfPlayerToRemove....(
2
)
2012-03-22 14:36:44.549 golf eScorer[3849:11f03] discardedId...(
2
)
这是我的代码行:
if([[ArrayOfGameidOfPlayerToRemove objectAtIndex:0] isEqualToString:[discardedId
objectAtIndex:0]])
{
[ArrayOfGameidOfPlayerToRemove replaceObjectAtIndex:0 withObject:emptyString];
}
更新:
我是这样解决的
NSMutableArray *ArrayOfGameidOfPlayerToRemove = [yournsarray mutableCopy];
最佳答案
似乎变量 ArrayOfGameidOfPlayerToRemove
是 NSArray
的实例。您只能在 NSMutableArray
关于iphone - 用空字符串替换数组对象时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9819220/