當兩個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