2016-12-04 16:31:16.519 BlogReader[1881:75140] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]' *** First throw call stack: ( 0 CoreFoundation 0x000000010ab4f34b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010a5b021e objc_exception_throw + 48 2 CoreFoundation 0x000000010aba7bdf -[__NSSingleObjectArrayI objectAtIndex:] + 111 3 UIKit 0x000000010b730fe9 -[UITableViewDataSource tableView:heightForRowAtIndexPath:] + 181 4 UIKit 0x000000010b39406b -[UITableViewController tableView:heightForRowAtIndexPath:] + 63 5 UIKit 0x000000010b0e9d7e -[UITableView _dataSourceHeightForRowAtIndexPath:] + 99 6 UIKit 0x000000010b323ac6 __66-[UISectionRowData refreshWithSection:tableView:tableViewRowData:]_block_invoke + 368 7 UIKit 0x000000010b323081 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 3375 8 UIKit 0x000000010b328d31 -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 501 9 UIKit 0x000000010b328e8f -[UITableViewRowData heightForTable] + 56 10 UIKit 0x000000010b0aaf36 -[UITableView _updateContentSize] + 381 11 UIKit 0x000000010b0d346f -[UITableView _rebuildGeometry] + 40 12 UIKit 0x000000010b0d16e3 -[UITableView setLayoutMargins:] + 282 13 UIKit 0x000000010b0d15a7 -[UITableView _setDefaultLayoutMargins:] + 103 14 UIKit 0x000000010b10a7dc -[UIViewController _setContentOverlayInsets:] + 646 15 UIKit 0x000000010b10b26c -[UIViewController _updateContentOverlayInsetsFromParentIfNecessary] + 2162 16 UIKit 0x000000010b10a859 -[UIViewController _updateContentOverlayInsetsForSelfAndChildren] + 101 17 UIKit 0x000000010b1162d8 -[UIViewController _updateLayoutForStatusBarAndInterfaceOrientation] + 1027 18 UIKit 0x000000010b11c002 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 1238 19 UIKit 0x000000010b030620 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1590 20 UIKit 0x000000010b0480e2 -[UIScrollView _didMoveFromWindow:toWindow:] + 85 21 UIKit 0x000000010b03031d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 819 22 UIKit 0x000000010b0236b4 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 151 23 UIKit 0x000000010b0235a2 -[UIView(Hierarchy) _postMovedFromSuperview:] + 857 24 UIKit 0x000000010b0332eb -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1982 25 UIKit 0x000000010b0217a1 -[UIView(Hierarchy) addSubview:] + 838 26 UIKit 0x000000010b43de77 -[UINavigationTransitionView transition:fromView:toView:] + 645 27 UIKit 0x000000010b155747 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3314 28 UIKit 0x000000010b155ce5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 874 29 UIKit 0x000000010b156dc7 -[UINavigationController __viewWillLayoutSubviews] + 58 30 UIKit 0x000000010b34dd6f -[UILayoutContainerView layoutSubviews] + 223 31 UIKit 0x000000010b036f50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237 32 QuartzCore 0x000000010f7b8cc4 -[CALayer layoutSublayers] + 146 33 QuartzCore 0x000000010f7ac788 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366 34 QuartzCore 0x000000010f7ac606 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24 35 QuartzCore 0x000000010f73a680 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280 36 QuartzCore 0x000000010f767767 _ZN2CA11Transaction6commitEv + 475 37 QuartzCore 0x000000010f7680d7 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113 38 CoreFoundation 0x000000010aaf3e17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 39 CoreFoundation 0x000000010aaf3d87 __CFRunLoopDoObservers + 391 40 CoreFoundation 0x000000010aad84b6 CFRunLoopRunSpecific + 454 41 UIKit 0x000000010af6c7e6 -[UIApplication _run] + 434 42 UIKit 0x000000010af72964 UIApplicationMain + 159 43 BlogReader 0x0000000109fd96ff main + 111 44 libdyld.dylib 0x000000010d92f68d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"showBlogPost"]){
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
BlogPost *blogPost = [self.blogPost objectAtIndex:indexPath.row];
[segue.destinationViewController setBlogPostURL:blogPost.url];
}
私は、問題が何であるかを知りません。NSRangeException理由
'indexPathForSelectedRow'は' nil'を返すことができます。それを確認する必要があります。 – vadian
投稿されたコードはエラーの原因ではありません。行の高さを取得しようとしているときに、エラーが深刻です。 – rmaddy