我正在學習Objecive-C並嘗試在循環中移除Object方法。 它無法正常工作。我收到「線程1:程序接收信號:」SIGABRT「。」在那條線上。 有什麼不對?Objective-C奇怪的錯誤SIGABRT
NSMutableArray *bookListMutable = [NSMutableArray arrayWithObjects:@"TitleM 2", @"TitleM 4", @"TitleM 5", nil];
[bookListMutable addObject:@"TitleM 3 added"];
[bookListMutable insertObject:@"TitleM 1 inserted" atIndex:0];
long countMutable;
countMutable = bookListMutable.count;
for(int y = 0; y < countMutable; y++){
[bookListMutable removeObject:[bookListMutable objectAtIndex:y]];
}
P.S. xCode 4.1
1)時間更新,有一個Xcode 4.3。 2)SIGABRT通常是一個例外。你檢查了控制檯嗎? – 2012-02-19 20:44:52
這是哪一行?另外,爲什麼不使用'removeObjectAtIndex:',或者'removeAllObjects' ?! – 2012-02-19 20:45:59
我試圖從這本書做練習http://www.amazon.com/Objective-C-Absolute-Beginners-iPhone-Programming/dp/1430228326/ref=sr_1_2?ie=UTF8&qid=1329685777&sr=8-2 – 2012-02-19 21:10:42