2012年3月13日火曜日

[super tableView:tableView heightForRowAtIndexPath:indexPath]でクラッシュ

表題の通り、iOS4.xだとなぜか

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [super tableView:tableView heightForRowAtIndexPath:indexPath];
}

というコードでクラッシュしてしまっていた。

2012-03-13 17:16:12.839 AZTableViewApp[17518:11303] -[AZTableViewController tableView:heightForRowAtIndexPath:]: unrecognized selector sent to instance 0x5c3aaf0
2012-03-13 17:16:18.694 AZTableViewApp[17518:11303] CRASH: -[AZTableViewController tableView:heightForRowAtIndexPath:]: unrecognized selector sent to instance 0x5c3aaf0
2012-03-13 17:16:18.696 AZTableViewApp[17518:11303] Stack Trace: (
	0   CoreFoundation                      0x0108a5a9 __exceptionPreprocess + 185
	1   libobjc.A.dylib                     0x011de313 objc_exception_throw + 44
	2   CoreFoundation                      0x0108c0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
	3   CoreFoundation                      0x00ffba04 ___forwarding___ + 1124
	4   CoreFoundation                      0x00ffb522 _CF_forwarding_prep_0 + 50
	5   AZTableViewApp                      0x000052a0 -[AZTableViewController tableView:heightForRowAtIndexPath:] + 384
	6   UIKit                               0x001ea6d5 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2888
	7   UIKit                               0x001e7d88 -[UITableViewRowData numberOfRows] + 108
	8   UIKit                               0x001eb82d -[UITableViewRowData globalRowsInRect:] + 36
	9   UIKit                               0x000ac261 -[UITableView(_UITableViewPrivate) _visibleGlobalRowsInRect:] + 178
	10  UIKit                               0x000ad382 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 207
	11  UIKit                               0x0009ca46 -[UITableView(_UITableViewPrivate) _updateVisibleCellsImmediatelyIfNecessary] + 56
	12  UIKit                               0x0009b395 -[UITableView visibleCells] + 39
	13  AZTableViewApp                      0x00004421 -[AZTableViewController viewWillAppear:] + 449
	14  UIKit                               0x000eb9be -[UINavigationController _startTransition:fromViewController:toViewController:] + 858
	15  UIKit                               0x000e632a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
	16  UIKit                               0x002012e9 -[UILayoutContainerView layoutSubviews] + 226
	17  QuartzCore                          0x01761a5a -[CALayer layoutSublayers] + 181
	18  QuartzCore                          0x01763ddc CALayerLayoutIfNeeded + 220
	19  QuartzCore                          0x017090b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
	20  QuartzCore                          0x0170a294 _ZN2CA11Transaction6commitEv + 292
	21  UIKit                               0x0002f9c9 -[UIApplication _reportAppLaunchFinished] + 39
	22  UIKit                               0x0002fe83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
	23  UIKit                               0x0003a617 -[UIApplication handleEvent:withNewEvent:] + 1533
	24  UIKit                               0x00032abf -[UIApplication sendEvent:] + 71
	25  UIKit                               0x00037f2e _UIApplicationHandleEvent + 7576
	26  GraphicsServices                    0x00d8b992 PurpleEventCallback + 1550
	27  CoreFoundation                      0x0106b944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
	28  CoreFoundation                      0x00fcbcf7 __CFRunLoopDoSource1 + 215
	29  CoreFoundation                      0x00fc8f83 __CFRunLoopRun + 979
	30  CoreFoundation                      0x00fc8840 CFRunLoopRunSpecific + 208
	31  CoreFoundation                      0x00fc8761 CFRunLoopRunInMode + 97
	32  UIKit                               0x0002f7d2 -[UIApplication _run] + 623
	33  UIKit                               0x0003bc93 UIApplicationMain + 1160
	34  AZTableViewApp                      0x0000281a main + 170
	35  AZTableViewApp                      0x00002765 start + 53
)
2012-03-13 17:16:18.697 AZTableViewApp[17518:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AZTableViewController tableView:heightForRowAtIndexPath:]: unrecognized selector sent to instance 0x5c3aaf0'
*** Call stack at first throw:
(
	0   CoreFoundation                      0x0108a5a9 __exceptionPreprocess + 185
	1   libobjc.A.dylib                     0x011de313 objc_exception_throw + 44
	2   CoreFoundation                      0x0108c0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
	3   CoreFoundation                      0x00ffba04 ___forwarding___ + 1124
	4   CoreFoundation                      0x00ffb522 _CF_forwarding_prep_0 + 50
	5   AZTableViewApp                      0x000052a0 -[AZTableViewController tableView:heightForRowAtIndexPath:] + 384
	6   UIKit                               0x001ea6d5 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2888
	7   UIKit                               0x001e7d88 -[UITableViewRowData numberOfRows] + 108
	8   UIKit                               0x001eb82d -[UITableViewRowData globalRowsInRect:] + 36
	9   UIKit                               0x000ac261 -[UITableView(_UITableViewPrivate) _visibleGlobalRowsInRect:] + 178
	10  UIKit                               0x000ad382 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 207
	11  UIKit                               0x0009ca46 -[UITableView(_UITableViewPrivate) _updateVisibleCellsImmediatelyIfNecessary] + 56
	12  UIKit                               0x0009b395 -[UITableView visibleCells] + 39
	13  AZTableViewApp                      0x00004421 -[AZTableViewController viewWillAppear:] + 449
	14  UIKit                               0x000eb9be -[UINavigationController _startTransition:fromViewController:toViewController:] + 858
	15  UIKit                               0x000e632a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
	16  UIKit                               0x002012e9 -[UILayoutContainerView layoutSubviews] + 226
	17  QuartzCore                          0x01761a5a -[CALayer layoutSublayers] + 181
	18  QuartzCore                          0x01763ddc CALayerLayoutIfNeeded + 220
	19  QuartzCore                          0x017090b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
	20  QuartzCore                          0x0170a294 _ZN2CA11Transaction6commitEv + 292
	21  UIKit                               0x0002f9c9 -[UIApplication _reportAppLaunchFinished] + 39
	22  UIKit                               0x0002fe83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
	23  UIKit                               0x0003a617 -[UIApplication handleEvent:withNewEvent:] + 1533
	24  UIKit                               0x00032abf -[UIApplication sendEvent:] + 71
	25  UIKit                               0x00037f2e _UIApplicationHandleEvent + 7576
	26  GraphicsServices                    0x00d8b992 PurpleEventCallback + 1550
	27  CoreFoundation                      0x0106b944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
	28  CoreFoundation                      0x00fcbcf7 __CFRunLoopDoSource1 + 215
	29  CoreFoundation                      0x00fc8f83 __CFRunLoopRun + 979
	30  CoreFoundation                      0x00fc8840 CFRunLoopRunSpecific + 208
	31  CoreFoundation                      0x00fc8761 CFRunLoopRunInMode + 97
	32  UIKit                               0x0002f7d2 -[UIApplication _run] + 623
	33  UIKit                               0x0003bc93 UIApplicationMain + 1160
	34  AZTableViewApp                      0x0000281a main + 170
	35  AZTableViewApp                      0x00002765 start + 53
)
Signal received: SIGABRT (Aborted)

なので、

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return self.tableView.rowHeight;
}

という感じにしたら問題なかった。

普通にUITableViewControllerそのもののサブクラスなので、特にsuperが問題にならないと思うんだけど何が原因だったんだろ。。