1

내 탐색 기반 응용 프로그램에서 네 가지보기가 있습니다. MainView, AddView, ShowView 및 DetailView. MainView에는 NSMutableArray가 있습니다. 버튼 추가를 클릭하면 AddView로 이동 한 다음 MainView의 NSMutable 배열에 객체를 추가합니다. 그럼 돌아와서 ShowView에 가서 tableView입니다. MAINVIEW에서이 같은 ShowView의 createList 함수를 호출하고 있습니다 : ShowView createList에서가끔 내 응용 프로그램이 작동을 멈추고 프로그램 수신 신호를주는 이유 : "SIGABRT"오류가 있습니까?

ShowView *show = [[ShowView alloc] init]; 
    [show createList: self.savedObjectsList]; 
    [self.navigationController pushViewController: show animated: YES]; 

    [runListController release]; 

은 다음과 같습니다 objList가 ShowView에있는 NSMutableArray입니다

- (void) createRunsList: (NSMutableArray *) list{ 
    objList = [list retain]; 

} 

합니다. 테이블 뷰의 모든 셀은 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 잘 작동하지만이 오류가 발생합니다. 미리 감사드립니다.

+0

배열에 범위 외 오류가있는 것 같습니다. 디버깅을 시도 했습니까? –

+0

테이블 뷰의 오른쪽 행을 보여줍니다. 예를 들어, 내가 4 개체를 추가하면 tableView에 4 개의 행이 표시됩니다. 때때로 그들 중 2 명은 잘 작동하고 2 명은 그렇지 않습니다. 때로는 3 개가 잘 작동하고 1 개는 제대로 작동하지 않습니다. – Piscean

답변

1

스택 추적을 보면 RunListViewController의 UITableView에서 행을 선택할 때 호출되는 [PostRunDetailViewController createRunDetail :] 메서드에서 예외가 발생합니다. 범위를 벗어난 배열의 요소에 액세스하려고합니다.

이 메서드의 시작 부분에 중단 점을 넣고 디버거에서 단계별로 실행하십시오. 어떤 배열 액세스가 예외를 일으키는 지 확인한 다음 배열에 원하는 요소가 포함되지 않은 이유를 생각하십시오.

0

그냥이 줄을 주석 : [runListController release];

관련 문제