线程1:Swift中的SIGABRT信号错误

时间:2015-12-31 06:50:55

标签: ios xcode swift

在构建我的应用时,我遇到了这个错误:

  

线程1:信号SIGABRT

在日志中,出现此消息

2015-12-30 19:47:06.362 Secondo B[785:20526] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.29.5/UITableView.m:6547
2015-12-30 19:47:06.376 Secondo B[785:20526] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
    0   CoreFoundation                      0x013c5a84 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x031f6e02 objc_exception_throw + 50
    2   CoreFoundation                      0x013c591a +[NSException raise:format:arguments:] + 138
    3   Foundation                          0x01800e86 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 118
    4   UIKit                               0x01eb027a -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 258
    5   Secondo B                           0x00071206 _TFC9Secondo_B26TableViewControllerCompiti9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 150
    6   Secondo B                           0x00071719 _TToFC9Secondo_B26TableViewControllerCompiti9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 89
    7   UIKit                               0x01ec4a19 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 782
    8   UIKit                               0x01ec4b47 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 90
    9   UIKit                               0x01e937f1 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3317
    10  UIKit                               0x01eb3cdd __29-[UITableView layoutSubviews]_block_invoke + 52
    11  UIKit                               0x01ece8f3 -[UITableView _performWithCachedTraitCollection:] + 88
    12  UIKit                               0x01eb3bb2 -[UITableView layoutSubviews] + 214
    13  UIKit                               0x01e08eb7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 813
    14  libobjc.A.dylib                     0x0320b059 -[NSObject performSelector:withObject:] + 70
    15  QuartzCore                          0x0065280a -[CALayer layoutSublayers] + 144
    16  QuartzCore                          0x006464ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
    17  QuartzCore                          0x00646352 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    18  QuartzCore                          0x00638e8b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
    19  QuartzCore                          0x0066ce03 _ZN2CA11Transaction6commitEv + 561
    20  QuartzCore                          0x0066d6c4 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    21  CoreFoundation                      0x012df61e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    22  CoreFoundation                      0x012df57e __CFRunLoopDoObservers + 398
    23  CoreFoundation                      0x012d4efc __CFRunLoopRun + 1340
    24  CoreFoundation                      0x012d4706 CFRunLoopRunSpecific + 470
    25  CoreFoundation                      0x012d451b CFRunLoopRunInMode + 123
    26  GraphicsServices                    0x05942664 GSEventRunModal + 192
    27  GraphicsServices                    0x059424a1 GSEventRun + 104
    28  UIKit                               0x01d3f1eb UIApplicationMain + 160
    29  Secondo B                           0x00075e5c main + 140
    30  libdyld.dylib                       0x03c64a21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

这是我在ViewController数据源中使用的代码

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)

    Compiti.text = self.messagesArray[indexPath.row]
    FotoCompiti.image = self.imagesArray[indexPath.row]
    DataCompiti.text = self.dateArray[indexPath.row]

    return cell
}

我还加倍检查可重用的小区标识符是否相同。

1 个答案:

答案 0 :(得分:1)

在cellforrowAtIndexPath

中更改此类逻辑
    var cell = UITableViewCell?
    cell=tableView.dequeueReusableCellWithIdentifier("ReUseCell")
    if cell==nil
    {
        cell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "ReUseCell")

    }
    Compiti.text = self.messagesArray[indexPath.row]
    FotoCompiti.image = self.imagesArray[indexPath.row]
    DataCompiti.text = self.dateArray[indexPath.row]

    return cell