周末发现一个BUG,时有时无,一出程序就崩溃,郁闷了好久,终于跟出来来了,记之,提醒自己今后一定规范编写,只要规范,绝对不会出问题

-- ::39.220 TTS[:] cell0 create
-- ::39.221 TTS[:] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.29./UITableView.m:
-- ::39.228 TTS[:] [ Uncaught Exception ]
Name: NSInternalInconsistencyException, Reason: UITableView (<UITableView: 0x7f84ba818600; frame = ( ; ); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7f84b955a7b0>; layer = <CALayer: 0x7f84b9555820>; contentOffset: {, }; contentSize: {, }>) failed to obtain a cell from its dataSource (<HomeViewController: 0x7f84b96b6a70>)
[ Fe Symbols Start ]
CoreFoundation 0x00000001104e1f45 __exceptionPreprocess +
libobjc.A.dylib 0x00000001145bddeb objc_exception_throw +
CoreFoundation 0x00000001104e1daa +[NSException raise:format:arguments:] +
Foundation 0x00000001142095ee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] +
UIKit 0x0000000112d8e960 -[UITableView _configureCellForDisplay:forIndexPath:] +
UIKit 0x0000000112d99e58 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] +
UIKit 0x0000000112d99f3f -[UITableView _createPreparedCellForGlobalRow:willDisplay:] +
UIKit 0x0000000112d6f307 -[UITableView _updateVisibleCellsNow:isRecursive:] +
UIKit 0x0000000112da2d1c -[UITableView _performWithCachedTraitCollection:] +
UIKit 0x0000000112d8a884 -[UITableView layoutSubviews] +
UIKit 0x0000000112cf8e40 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] +
QuartzCore 0x00000001123f559a -[CALayer layoutSublayers] +
QuartzCore 0x00000001123e9e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE +
QuartzCore 0x00000001123e9cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE +
QuartzCore 0x00000001123de475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE +
QuartzCore 0x000000011240bc0a _ZN2CA11Transaction6commitEv +
QuartzCore 0x000000011240c37c _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv +
CoreFoundation 0x000000011040d947 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ +
CoreFoundation 0x000000011040d8b7 __CFRunLoopDoObservers +
CoreFoundation 0x000000011040350b __CFRunLoopRun +
CoreFoundation 0x0000000110402e08 CFRunLoopRunSpecific +
GraphicsServices 0x00000001163a7ad2 GSEventRunModal +
UIKit 0x0000000112c4430d UIApplicationMain +
TTS 0x000000010f9f8f5f main +
libdyld.dylib 0x00000001150e392d start +
??? 0x0000000000000001 0x0 +
[ Fe Symbols End ]

tableview加载时,在cellForRowAtIndexPath里会报错,这是因为里面确实返回了nil的cell,一定要相信程序给你的反馈

                self.dataArray = [NSMutableArray arrayWithArray:award_array];
[self.dataArray insertObject:[NSNull null] atIndex:];
if (self.recommendAppDic)
[self.dataArray insertObject:self.recommendAppDic atIndex:];
self.dataArray = [NSMutableArray arrayWithArray:award_array];
if (self.recommendAppDic)
[self.dataArray insertObject:self.recommendAppDic atIndex:];
[self.dataArray insertObject:[NSNull null] atIndex:];

看看上面两块代码有什么区别.

看看上面

上一篇:使用Hibernate框架技术时,对项目进行的配置


下一篇:Docker-compose command 有多个命令例子