I am trying to set the Right Detail of a cell in a UITableView programmatically using Swift 3.
However, I'm unable to call the detailTextLabel.text
to set it.
Currently, I have this screen. As seen, I need to set Signed in as:
programmatically using a UserDefaults
value.
I've also set the Identifier of the cell:
This is what I have tried:
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "user_Cell", for: indexPath)
let prefs:UserDefaults = UserDefaults.standard
let user = prefs.value(forKey: "USER") as? String
cell.detailTextLabel?.text = user
return cell
}
However, it returns an error:
*** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:],
/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/UITableView.m:6600
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier user_Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'