Ios 线程1:信号SIGABRT错误(Swift 2)
我正在创建一个table应用程序(来自AppCoda的教程),但是运行程序时出现错误Ios 线程1:信号SIGABRT错误(Swift 2),ios,swift,sigabrt,Ios,Swift,Sigabrt,我正在创建一个table应用程序(来自AppCoda的教程),但是运行程序时出现错误Thread 1:signal SIGABRT。调试区域显示: 2015-10-26 14:47:34.827 FoodPin[4232:291494] Unknown class _TtC1q23RestaurantTableViewCell in Interface Builder file. 2015-10-26 14:47:34.855 FoodPin[4232:291494] *** Terminat
Thread 1:signal SIGABRT
。调试区域显示:
2015-10-26 14:47:34.827 FoodPin[4232:291494] Unknown class _TtC1q23RestaurantTableViewCell in Interface Builder file.
2015-10-26 14:47:34.855 FoodPin[4232:291494] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UITableViewCell 0x7f8062ca81d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key locationLabel.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000104a8df65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010671fdeb objc_exception_throw + 48
2 CoreFoundation 0x0000000104a8dba9 -[NSException raise] + 9
3 Foundation 0x0000000104e55f5b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x0000000105358c4b -[UIView(CALayerDelegate) setValue:forKey:] + 173
5 UIKit 0x0000000105648923 -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x00000001049ceb10 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x0000000105647306 -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x00000001053e52a5 -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 388
9 UIKit 0x00000001053e5677 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 71
10 FoodPin 0x00000001048a5d85 _TFC7FoodPin29RestaurantTableViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 197
11 FoodPin 0x00000001048a646f _TToFC7FoodPin29RestaurantTableViewController9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 79
12 UIKit 0x00000001053f76b3 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 782
13 UIKit 0x00000001053f77c8 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
14 UIKit 0x00000001053cd650 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3187
15 UIKit 0x0000000105400595 -[UITableView _performWithCachedTraitCollection:] + 92
16 UIKit 0x00000001053e89ad -[UITableView layoutSubviews] + 218
17 UIKit 0x000000010535911c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 710
18 QuartzCore 0x000000010976036a -[CALayer layoutSublayers] + 146
19 QuartzCore 0x0000000109754bd0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
20 QuartzCore 0x0000000109754a4e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
21 QuartzCore 0x00000001097491d5 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
22 QuartzCore 0x00000001097769f0 _ZN2CA11Transaction6commitEv + 508
23 QuartzCore 0x0000000109777154 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
24 CoreFoundation 0x00000001049b99d7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
25 CoreFoundation 0x00000001049b9947 __CFRunLoopDoObservers + 391
26 CoreFoundation 0x00000001049aeebc CFRunLoopRunSpecific + 524
27 UIKit 0x00000001052a398d -[UIApplication _run] + 402
28 UIKit 0x00000001052a8676 UIApplicationMain + 171
29 FoodPin 0x00000001048abb0d main + 109
30 libdyld.dylib 0x000000010723792d start + 1
31 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
自定义单元格:
import UIKit
class RestaurantTableViewCell: UITableViewCell {
@IBOutlet var nameLabel: UILabel!
@IBOutlet var locationLabel: UILabel!
@IBOutlet var typeLabel: UILabel!
@IBOutlet var thumbnailImageView: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
我的所有插座都连接到正确的标签/图像。我试着连接和断开它们,但没用
这是我的主要情节提要:
如果没有看到异常的开头,我的最佳猜测是您没有在情节提要中为单元格提供正确的
重用标识符,或者您没有将单元格设置为自定义类
此类不符合key locationLabel的键值编码
这意味着未设置locationLabel
的插座。因此,您的代码正在崩溃,因为它试图访问一个为零的变量(在本例中是一个出口)。您使用的是故事板吗?如果是这样,我们可以有一张图片吗?如果图片不在线,只在我的桌面上,我如何添加图片@CharlesTruluckYou可以在post编辑器中上传它。只需点击屏幕底部的编辑
,然后选择图片图标
。然后可以将其从桌面拖到浏览器窗口。(如果这是你的意思)点击链接查看我的Xcode屏幕@CharlesTruluckI,看看有更多的错误,如pbush25所说。向上滚动并将我们粘贴到错误报告的顶部。我在自己的代码中多次看到这一点:(很快就学会了找到这个!这很有帮助!谢谢@Swinny89谢谢@CharlesTruluckI不得不回到这个问题上来,因为在我测试它时,它实际上没有工作。我已经更新了我的代码,你可以在上面看到。@Swinny89实际上刚刚修复了它,谢谢你的帮助!@swiny89
import UIKit
class RestaurantTableViewCell: UITableViewCell {
@IBOutlet var nameLabel: UILabel!
@IBOutlet var locationLabel: UILabel!
@IBOutlet var typeLabel: UILabel!
@IBOutlet var thumbnailImageView: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}