我的视图控制器只有一个UITableView
:
当我尝试移动到此选项卡时,出现Signal SIGBRT错误。 这是我的代码。
//
// FriendTableViewController.swift
// Tiat
//
// Created by 이종승 on 2016. 9. 23..
// Copyright © 2016년 JW. All rights reserved.
//
import UIKit
import Firebase
class FriendTableViewController: UITableViewController {
var users = [User]()
let cellId = "friendsCell"
override func viewDidLoad() {
super.viewDidLoad()
fetchUser()
}
@IBOutlet var ttableView: UITableView!
func fetchUser () {
FIRDatabase.database().reference().child("users").observe(.childAdded, with: {snapshot in
if let dictionary = snapshot.value as? [String: AnyObject] {
let user = User()
user.name = dictionary["name"] as? String
user.gender = dictionary["gender"] as? String
user.birthday = dictionary["birthday"] as? String
user.point = dictionary["point"] as? Int
print(user.name, user.gender, user.birthday, user.point)
self.users.append(user)
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
})
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return users.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .subtitle, reuseIdentifier: cellId)
let user = users[indexPath.row]
cell.textLabel?.text = user.name
return cell
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
//错误日志//
2016-09-23 23:49:33.092 Tiat[14923:1376968] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "8rJ-Kc-sve-view-QS5-Rx-YEW" nib but didn't get a UITableView.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f94734b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010f3a821e objc_exception_throw + 48
2 CoreFoundation 0x000000010f9b0265 +[NSException raise:format:] + 197
3 UIKit 0x000000011018b7d2 -[UITableViewController loadView] + 532
4 UIKit 0x000000010ff0bc4c -[UIViewController loadViewIfRequired] + 201
5 UIKit 0x000000010ff4c44f -[UINavigationController _layoutViewController:] + 55
6 UIKit 0x000000010ff4cd37 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 471
7 UIKit 0x000000010ff4ceae -[UINavigationController _startTransition:fromViewController:toViewController:] + 133
8 UIKit 0x000000010ff4e0b9 -[UINavigationController _startDeferredTransitionIfNeeded:] + 874
9 UIKit 0x000000010ff4f19b -[UINavigationController __viewWillLayoutSubviews] + 58
10 UIKit 0x00000001101461b7 -[UILayoutContainerView layoutSubviews] + 223
11 UIKit 0x000000010fe2f344 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
12 QuartzCore 0x0000000114ba4cdc -[CALayer layoutSublayers] + 146
13 QuartzCore 0x0000000114b987a0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
14 QuartzCore 0x0000000114b9861e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
15 QuartzCore 0x0000000114b2662c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
16 QuartzCore 0x0000000114b53713 _ZN2CA11Transaction6commitEv + 475
17 UIKit 0x000000010fd64067 _UIApplicationFlushRunLoopCATransactionIfTooLate + 206
18 UIKit 0x0000000110573b30 __handleEventQueue + 5672
19 CoreFoundation 0x000000010f8ec311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
20 CoreFoundation 0x000000010f8d159c __CFRunLoopDoSources0 + 556
21 CoreFoundation 0x000000010f8d0a86 __CFRunLoopRun + 918
22 CoreFoundation 0x000000010f8d0494 CFRunLoopRunSpecific + 420
23 GraphicsServices 0x0000000112696a6f GSEventRunModal + 161
24 UIKit 0x000000010fd6af34 UIApplicationMain + 159
25 Tiat 0x000000010cdcc6cf main + 111
26 libdyld.dylib 0x0000000111f8e68d start + 1
27 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
被修改
还有一件非常奇怪的事情。
我尝试删除所有代码时运行我的代码,并且出现与以前相同的错误!
答案 0 :(得分:1)
猜猜,你还没有创建一个原型单元格。
向此tableview添加一个单元格,并为其指定已分配给cellId
的标识符名称。