I use Xcode7
i register the cell in viewDidLoad()
let SLQHomeTableViewCellID = "SLQHomeTableViewCellID"
self.tableView.registerClass(SLQStatusCell.self, forCellReuseIdentifier: SLQHomeTableViewCellID)
then the dataSouce like below:
// MARK: - Table view data source
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return statuses?.count ?? 0
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(SLQHomeTableViewCellID, forIndexPath: indexPath) as! SLQStatusCell
let status = statuses![indexPath.row]
cell.status = status
return cell
}
i also override init()
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
// 初始化UI
setupUI()
}
but when i run in simulator ,it's a fatal error in register cell ,this line is the error appeared
self.tableView.registerClass(SLQStatusCell.self, forCellReuseIdentifier: SLQHomeTableViewCellID)
fatal error: unexpectedly found nil while unwrapping an Optional value
i want to why,i run the program in using OC is all right.