Is anyone else having an issue using the tableView.registerClass
method with Swift?
It no longer comes in code completion for me (nor can I use it if manual
For swift 3 refer this. It works!
Inside you viewdidload function
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "LabelCell")
Switching the order in which I called registerNib and registerClass worked for me!
For some reason my app crashed when I had:
...registerNib.....
...registerClass...
But ran fine when I had:
...registerClass...
...registerNib.....
Hope that helps some of you.
For swift 4
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
Swift has once again renamed it to
tableView.register(UITableViewCell.self, forCellReuseIdentifier:"DefaultCell")
Really don't understand why they bothered so much about this particular naming
It works for me perfectly.
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
Exactly as I have it above.
I prefer to use TableViewCell.self to generate the identifier string. It can reduce the typing error.
tableView.register(MyCell.self, forCellReuseIdentifier: String(describing: MyCell.self))