返回所有单元格后,奇怪的SIGABRT崩溃

时间:2014-08-02 20:16:44

标签: ios objective-c uitableview

过去两天我一直试图解决这个问题,但我无法找到原因,所以我把它带到这里询问你们是否有任何想法。

所以我有一个UITableView我会显示一些项目。我还有UITableViewCell我用作单元格。

我在viewDidLoad

中使用我的表视图注册了nib
[self.QuickPickDetailsTV registerNib:[UINib nibWithNibName:@"QuickPickItemCell"
                                                        bundle:[NSBundle mainBundle]]
                  forCellReuseIdentifier:@"QuickPickItemCellReuseID"];

然后在tableView:cellForRowAtIndexPath:中,我重复使用,填充并返回单元格,如下所示:

static NSString *CellIdentifier = @"QuickPickItemCellReuseID";
QuickPickItemCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[QuickPickItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
}

NSDictionary *quickPickItem = [self.myQuickPickItems objectAtIndex:indexPath.row];
NSString *theQuickPickItemName = [quickPickItem valueForKey:@"name"];

[cell.mName setFont:[UIFont fontWithName:@"OpenSans" size:16]];
[cell.mName setText:NSLocalizedString(theQuickPickItemName, nil)];

return cell;

上面的方法会调用它应该显示的项目数(如预期的那样),并在返回 last 单元格后发生奇怪的错误:

2014-08-02 13:03:38.008 TestApp[49701:607] -[__NSArrayI length]: unrecognized selector sent to instance 0x2e92fde0
2014-08-02 13:03:38.010 TestApp[49701:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x2e92fde0'
*** First throw call stack:
(
    0   CoreFoundation                      0x044f21e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x033888e5 objc_exception_throw + 44
    2   CoreFoundation                      0x0458f243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x044e250b ___forwarding___ + 1019
    4   CoreFoundation                      0x044e20ee _CF_forwarding_prep_0 + 14
    5   UIKit                               0x01ff8463 -[UILabel _shadow] + 45
    6   UIKit                               0x01ff98c2 -[UILabel drawTextInRect:] + 70
    7   UIKit                               0x01ffbdfc -[UILabel drawRect:] + 98
    8   UIKit                               0x01eaa453 -[UIView(CALayerDelegate) drawLayer:inContext:] + 504
    9   QuartzCore                          0x00dbaf39 -[CALayer drawInContext:] + 123
    10  QuartzCore                          0x00dbae6a _ZL16backing_callbackP9CGContextPv + 96
    11  QuartzCore                          0x00ca94fc CABackingStoreUpdate_ + 2656
    12  QuartzCore                          0x00dbae02 ___ZN2CA5Layer8display_Ev_block_invoke + 93
    13  QuartzCore                          0x00def2d7 x_blame_allocations + 15
    14  QuartzCore                          0x00dbac6d _ZN2CA5Layer8display_Ev + 1519
    15  QuartzCore                          0x00dbaeb9 -[CALayer _display] + 33
    16  QuartzCore                          0x00dba676 _ZN2CA5Layer7displayEv + 144
    17  QuartzCore                          0x00dbae93 -[CALayer display] + 33
    18  QuartzCore                          0x00daf043 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 323
    19  QuartzCore                          0x00daf0bc _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 38
    20  QuartzCore                          0x00d157fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    21  QuartzCore                          0x00d16b85 _ZN2CA11Transaction6commitEv + 393
    22  QuartzCore                          0x00d17258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    23  CoreFoundation                      0x044ba36e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    24  CoreFoundation                      0x044ba2bf __CFRunLoopDoObservers + 399
    25  CoreFoundation                      0x04498254 __CFRunLoopRun + 1076
    26  CoreFoundation                      0x044979d3 CFRunLoopRunSpecific + 467
    27  CoreFoundation                      0x044977eb CFRunLoopRunInMode + 123
    28  GraphicsServices                    0x047e95ee GSEventRunModal + 192
    29  GraphicsServices                    0x047e942b GSEventRun + 104
    30  UIKit                               0x01e3bf9b UIApplicationMain + 1225
    31  TestApp                             0x00002c92 main + 130
    32  TestApp                             0x00002c05 start + 53
    33  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我搜索了所有代码,但是我没有将length发送到代码中的任何对象。我不知道崩溃发生在哪里,因为它显示在main.m上。

我也试过启用NSZombies,但我没有收到有关已发布对象的警告。

任何帮助将不胜感激!

由于

0 个答案:

没有答案