簡體   English   中英

在iPhone上測試應用程序時出錯,但模擬器中沒有錯誤

[英]Error when testing application on iPhone, but no error in simulator

當我在iPhone上測試我的應用程序時,出現以下錯誤,但該錯誤未在模擬器中發生。 當我加載作為UITableView的rootViewController時。 我對iOS編程還比較陌生,我只是想知道是否有人可以對此有所了解! 問候,邁克爾。 使用此代碼轉到我的RootView。

- (IBAction)goToRootView {
RootViewController *rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:rootViewController animated:YES];
[rootViewController release];

}

2011-09-12 14:39:55.951 LeagueProject[773: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                      0x3684b64f __exceptionPreprocess + 114
        1   libobjc.A.dylib                     0x33aa4c5d objc_exception_throw + 24
        2   CoreFoundation                      0x367b6069 -[__NSArrayM objectAtIndex:] + 184
        3   LeagueProject                       0x0000302f -[RootViewController tableView:numberOfRowsInSection:] + 58
        4   UIKit                               0x356827c7 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1338
        5   UIKit                               0x356836bb -[UITableViewRowData rectForFooterInSection:] + 66
        6   UIKit                               0x356835f5 -[UITableViewRowData heightForTable] + 40
        7   UIKit                               0x35683453 -[UITableView(_UITableViewPrivate) _updateContentSize] + 206
        8   UIKit                               0x3567ebc9 -[UITableView _rectChangedWithNewSize:oldSize:] + 384
        9   UIKit                               0x3567d833 -[UITableView setFrame:] + 158
        10  UIKit                               0x35684e0f -[UIView(Geometry) resizeWithOldSuperviewSize:] + 274
        11  UIKit                               0x356510bd -[UIView(Geometry) resizeSubviewsWithOldSize:] + 120
        12  UIKit                               0x356364e9 -[UIView(Geometry) setFrame:] + 336
        13  UIKit                               0x35688193 -[UIViewControllerWrapperView setFrame:] + 62
        14  UIKit                               0x35676079 -[UINavigationController _startTransition:fromViewController:toViewController:] + 960
        15  UIKit                               0x35675c43 -[UINavigationController _startDeferredTransitionIfNeeded] + 182
        16  UIKit                               0x35667d5d -[UINavigationController pushViewController:transition:forceImmediate:] + 640
        17  UIKit                               0x35667ad3 -[UINavigationController pushViewController:animated:] + 34
        18  LeagueProject                       0x0000917d -[splashView goToRootView] + 116
        19  CoreFoundation                      0x367bb571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
        20  UIKit                               0x3564dec9 -[UIApplication sendAction:to:from:forEvent:] + 84
        21  UIKit                               0x3564de69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
        22  UIKit                               0x3564de3b -[UIControl sendAction:to:forEvent:] + 38
        23  UIKit                               0x3564db8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
        24  UIKit                               0x3564e423 -[UIControl touchesEnded:withEvent:] + 342
        25  UIKit                               0x3564cbf5 -[UIWindow _sendTouchesForEvent:] + 368
        26  UIKit                               0x3564c56f -[UIWindow sendEvent:] + 262
        27  UIKit                               0x35635313 -[UIApplication sendEvent:] + 298
        28  UIKit                               0x35634c53 _UIApplicationHandleEvent + 5090
        29  GraphicsServices                    0x35f6fe77 PurpleEventCallback + 666
        30  CoreFoundation                      0x36822a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
        31  CoreFoundation                      0x3682483f __CFRunLoopDoSource1 + 166
        32  CoreFoundation                      0x3682560d __CFRunLoopRun + 520
        33  CoreFoundation                      0x367b5ec3 CFRunLoopRunSpecific + 230
        34  CoreFoundation                      0x367b5dcb CFRunLoopRunInMode + 58
        35  GraphicsServices                    0x35f6f41f GSEventRunModal + 114
        36  GraphicsServices                    0x35f6f4cb GSEventRun + 62
        37  UIKit                               0x3565fd69 -[UIApplication _run] + 404
        38  UIKit                               0x3565d807 UIApplicationMain + 670
        39  LeagueProject                       0x000025a7 main + 82
        40  LeagueProject                       0x00002550 start + 40
    )
    terminate called after throwing an instance of 'NSException'

您的錯誤是index 0 beyond bounds for empty array錯誤index 0 beyond bounds for empty arrayindex 0 beyond bounds for empty array 在訪問數組的行上放置斷點。 當您找出導致問題的陣列時,解決方案將是微不足道的,或者您可以在問題中添加更多內容並尋求進一步的幫助。

看來問題出在[RootViewController tableView:numberOfRowsInSection:]的實現中。 您正在嘗試訪問一個NSMutableArray成員,該成員為空-因此出現錯誤“索引0超出了空數組的范圍”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM