为什么有时我的应用程序停止工作并给出程序接收信号:“SIGABRT”错误?
我的基于导航的应用程序中有四个视图。 MainView、AddView、ShowView 和 DetailView。 MainView 有一个 NSMutableArray。当我单击添加按钮时,我会转到 AddView,然后在 MainView 的 NSMutable 数组中添加一个对象。然后我回来并转到 ShowView,它是一个 tableView。从 MainView 中,我调用 ShowView 的 createList 函数,如下所示:
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 是 ShowView 中的 NSMutableArray。表视图的每个单元格都会创建一个 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 工作正常,但后来我收到此错误。提前致谢。
I have four views in my navigational based application. MainView, AddView, ShowView and DetailView. MainView has a NSMutableArray. When i click on button add, then i go to AddView and then i add an object in NSMutable array of MainView. Then i come back and go to ShowView which is a tableView. From MainView i am calling createList function of ShowView like this:
ShowView *show = [[ShowView alloc] init];
[show createList: self.savedObjectsList];
[self.navigationController pushViewController: show animated: YES];
[runListController release];
In ShowView createList looks like this:
- (void) createRunsList: (NSMutableArray *) list{
objList = [list retain];
}
where objList is NSMutableArray in ShowView. every cell of table view creates a DetailView of an object of NSMutbaleArray. Problem is sometimes my applications stop working and i get this error:
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)
Can anybody tell me why is it happening? DetailView of some first objects works fine but then i get this error. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看堆栈跟踪,会在 [PostRunDetailViewController createRunDetail:] 方法中引发异常,当您在 RunListViewController 的 UITableView 中选择一行时会调用该方法。您正在尝试访问数组中越界的元素。
在此方法的开头放置一个断点,并在调试器中单步执行它。找出哪个数组访问导致了异常,然后思考为什么该数组可能不包含您期望的元素。
Looking at the stack trace, the exception is thrown in your [PostRunDetailViewController createRunDetail:] method, which is called when you select a row in your RunListViewController's UITableView. You are trying to access an element in the array that is out of bounds.
Put a break point at the start of this method and step through it in the debugger. Work out which array access is causing the exception and then think why the array might not contain the elements that you expect.
只需评论这一行
[runListController发布];
Just comment this line
[runListController release];