2011-09-12 15 views
0

iPhoneでアプリケーションをテストすると以下のエラーが表示されますが、シミュレータでエラーは発生しません。そのとき、私はrootViewControllerをロードします。これはUITableViewです。私は、iOSプログラミングには比較的新しいので、誰かがそれに光を当てることができるかどうか疑問に思っていました! よろしく、 マイケル。 このコードを使用して、自分のルートビューに移動します。iPhoneでアプリケーションをテストするとエラーが発生しますが、シミュレータでエラーは発生しません

- (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' 
+1

クラッシュログをもっと慎重に読んでください - tableViewにエラーがあります:numberOfRowsInSection:RootViewControllerのメソッド - 可能な問題を探す必要があります – Vladimir

+2

あなたのシミュレータはどのバージョンのiOSですか?作成しているアプリケーションのビルドはどのバージョンですか(プロパティのベースSDKのバージョン)ですか?最後に、あなたのデバイス上のiOSはどのバージョンですか? – ApolloSoftware

+0

また、Xcodeのドロップダウンに「iOS Device」と表示されていないことを確認してください。 – ApolloSoftware

答えて

1

あなたのエラーがindex 0 beyond bounds for empty arrayエラーです。配列にアクセスする行にブレークポイントを設定します。どちらの配列が問題を引き起こしているかを知ると、解決策は簡単になるか、もう少し質問に追加してさらに助けを求めることができます。

+0

返事をありがとう。私は答えを待っている間にこれを見て、NSLoggedは私が配列のものになるインターネットからダウンロードしたデータの一部をログに記録しました。私はRegexのものを使って、私が望んでいたウィキペディアの記事の一部を見つけ出しました。そして編集の期間が終わったので、コードの一部が今日のhtmlから消えました(情報は、最後の夜に終了しました)。だから今朝私は[編集]しないように変更しましたが、iPhoneはまだ[編集]を見るようです。たぶんブラウジングの矛盾?わからない! –

+0

ウェブサイトから情報を読むことは、通常は制御できません。サイトのフォーマットを保証することはできません。彼らは異なるサーバ/ブラウザなどを介して矛盾するだけでなく、明日の完全な見直しを行うかもしれません! 私はWikipedia APIを探すことをお勧めしますが、そのようなことが存在するかどうかはわかりません。 –

+0

ええ、ウィキメディアのインフォメーションを当面使用していると、数週間後にウェブサイトにアクセスする必要がありますが、時間の問題があるため、私がこれまで行ってきたことを示す必要があります。男の助けをありがとう、私は問題の周りに正規表現できるかどうかを確認します! –

0

[RootViewController tableView:numberOfRowsInSection:]の実装に問題があるようです。空のNSMutableArrayのメンバーにアクセスしようとしています。つまり、 '空の配列の境界を越えるインデックス0'というエラーです。

関連する問題