当两个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];
中替换对象要澄清,您试图删除/替换/修改不可变数组的内容! – theiOSDude 2012-03-22 09:20:09