I have a custom UITableViewCell in Swift 3 (let's call it MyCustomTableViewCell) and it has an identifier "CustomCell".
If I use my custom cell without registering it for reuse, it works fine in
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath) as! MyCustomTableViewCell
return cell
}
If I try to register it for reuse via
override func viewDidLoad() {
super.viewDidLoad()
myUITableViewThatIsIBOutlet.register(MyCustomTableViewCell.self, forCellReuseIdentifier: "CustomCell")
}
when I try to access the table I get "fatal error: unexpectedlyfound nil while unwrapping an Optional value" and the UILabels in my custom cell are showing up as "nil" (which is presumably what's causing the fatal error).
Am I doing something wrong when I register the custom cell, or am I supposed to not register a custom cell for reuse?