UITableView - registerClass with Swift

It works for me perfectly.

self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")

Exactly as I have it above.


For Swift 2.2 Register For Default Cell From Class

self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "DefaultCell")



For Swift 3.0 Register For Default Cell From Class

self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "DefaultCell")



For Swift 2.2 Register For Default Cell From Nib

self.tableView.registerNib(UINib(nibName: "CustomCellName", bundle: nil), forCellReuseIdentifier: "CustomCellIdentifer")



For Swift 3.0 Register For Default Cell From Nib

self.tableView.registerNib(UINib(nibName: "CustomCellName", bundle: nil), forCellReuseIdentifier: "CustomCellName")

Note: Storyboard created cell is called prototype cell and have some procedure to register prototype cell like Nib.And Don't forget to set the cell identifier like below. enter image description here


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