failed to obtain a cell from its dataSource

独立写一下汽车品牌展示,发现了以下这个错。原来。。

static NSString *ID = @"car_cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    }

重用单元格,多写了UITableViewCell *。。。。多建了一次。。。。。

要写成:cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];



2016-02-20 19:21:16.823 6carsBrand-2 myself1[2632:146889] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UITableView.m:7927

2016-02-20 19:21:16.827 6carsBrand-2 myself1[2632:146889] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView (; layer = ; contentOffset: {0, 0}; contentSize: {182, 6792}>) failed to obtain a cell from its dataSource ()'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010e4a0f65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010df1adeb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010e4a0dca +[NSException raise:format:arguments:] + 106
    3   Foundation                          0x000000010db68ae2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
    4   UIKit                               0x000000010e991879 -[UITableView _configureCellForDisplay:forIndexPath:] + 225
    5   UIKit                               0x000000010e99c6e1 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 828
    6   UIKit                               0x000000010e99c7c8 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
    7   UIKit                               0x000000010e972650 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3187
    8   UIKit                               0x000000010e9a5595 -[UITableView _performWithCachedTraitCollection:] + 92
    9   UIKit                               0x000000010e98d9ad -[UITableView layoutSubviews] + 218
    10  UIKit                               0x000000010e8fe11c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 710
    11  QuartzCore                          0x000000011231036a -[CALayer layoutSublayers] + 146
    12  QuartzCore                          0x0000000112304bd0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
    13  QuartzCore                          0x0000000112304a4e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    14  QuartzCore                          0x00000001122f91d5 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
    15  QuartzCore                          0x00000001123269f0 _ZN2CA11Transaction6commitEv + 508
    16  QuartzCore                          0x0000000112327154 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    17  CoreFoundation                      0x000000010e3cc9d7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    18  CoreFoundation                      0x000000010e3cc947 __CFRunLoopDoObservers + 391
    19  CoreFoundation                      0x000000010e3c1ebc CFRunLoopRunSpecific + 524
    20  UIKit                               0x000000010e84898d -[UIApplication _run] + 402
    21  UIKit                               0x000000010e84d676 UIApplicationMain + 171
    22  6carsBrand-2 myself1                0x000000010da172bf main + 111
    23  libdyld.dylib                       0x0000000110b2c92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

你可能感兴趣的:(failed to obtain a cell from its dataSource)