我在基於導航的應用程序中有四種視圖。 MainView,AddView,ShowView和DetailView。 MainView有一個NSMutableArray。當我點擊按鈕添加,然後我去AddView,然後我在MainView的NSMutable數組中添加一個對象。然後我回來,並去ShowView這是一個tableView。從的MainView我打電話ShowView的createList功能是這樣的:爲什麼有時我的應用程序停止工作並給程序接收信號:「SIGABRT」錯誤?
ShowView *show = [[ShowView alloc] init];
[show createList: self.savedObjectsList];
[self.navigationController pushViewController: show animated: YES];
[runListController release];
在ShowView createList看起來是這樣的:
- (void) createRunsList: (NSMutableArray *) list{
objList = [list retain];
}
其中objList是在的NSMutableArray ShowView。表視圖的每個單元格都會創建一個NSMutbaleArray對象的DetailView。問題是有時我的應用程序停止工作,我得到這個錯誤:
2011-10-03 15:35:55.076 RunnoIPhoneApp[2750:707] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array'
*** Call stack at first throw:
(
0 CoreFoundation 0x3399964f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x30b16c5d objc_exception_throw + 24
2 CoreFoundation 0x33904069 -[__NSArrayM objectAtIndex:] + 184
3 RunnoIPhoneApp 0x0000b79f -[PostRunDetailViewController createRunDetail:] + 90
4 RunnoIPhoneApp 0x0000fd2f -[RunListViewController tableView:didSelectRowAtIndexPath:] + 182
5 UIKit 0x3203f51b -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 662
6 UIKit 0x320a30eb -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 130
7 Foundation 0x32ba26d5 __NSFireDelayedPerform + 368
8 CoreFoundation 0x33970a47 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
9 CoreFoundation 0x33972ecb __CFRunLoopDoTimer + 850
10 CoreFoundation 0x33973845 __CFRunLoopRun + 1088
11 CoreFoundation 0x33903ec3 CFRunLoopRunSpecific + 230
12 CoreFoundation 0x33903dcb CFRunLoopRunInMode + 58
13 GraphicsServices 0x3162e41f GSEventRunModal + 114
14 GraphicsServices 0x3162e4cb GSEventRun + 62
15 UIKit 0x32019d69 -[UIApplication _run] + 404
16 UIKit 0x32017807 UIApplicationMain + 670
17 RunnoIPhoneApp 0x00002553 main + 70
18 RunnoIPhoneApp 0x00002508 start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal: 「SIGABRT」.
warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.5 (8L1)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
Program received signal: 「SIGABRT」.
(gdb)
有人可以告訴我爲什麼會發生?一些第一個對象的DetailView工作正常,但是然後我得到這個錯誤。提前致謝。
看起來你有一個數組越界的錯誤 - 你嘗試調試它嗎? –
其顯示正確數量的tableView行。例如,如果我添加了4個對象,它會在tableView中顯示4行。有時候2個工作正常,2個不工作。有時3個工作正常,1個工作不正常。 – Piscean