@@ -130,7 +130,7 @@ final class CustomCell: UITableViewCell, Reusable { /* And that's it! */ }
130130``` swift
131131final class CodeBasedCustomCell : UITableViewCell , Reusable {
132132 // By default this cell will have a reuseIdentifier of "CodeBasedCustomCell"
133- // unless you provide an alternative implementation of `var reuseIdentifier`
133+ // unless you provide an alternative implementation of `static var reuseIdentifier`
134134
135135 // No need to add anything to conform to Reusable. You can just keep your normal cell code
136136 @IBOutlet private weak var label: UILabel!
@@ -148,7 +148,7 @@ final class NibBasedCustomCell: UITableViewCell, NibReusable {
148148// final class NibBasedCustomCell: UITableViewCell, Reusable, NibLoadable {
149149
150150 // Here we provide a nib for this cell class (which, if we don't override the protocol's
151- // default implementation of `nib`, will use a XIB of the same name as the class)
151+ // default implementation of `static var nib: UINib `, will use a XIB of the same name as the class)
152152
153153 // No need to add anything to conform to Reusable. You can just keep your normal cell code
154154 @IBOutlet private weak var pictureView: UIImageView!
@@ -204,8 +204,12 @@ class MyViewController: UIViewController {
204204
205205 override func viewDidLoad () {
206206 super .viewDidLoad ()
207- tableView.register (cellType : CodeBasedCustomCell.self ) // This will register using the class without using a UINib
208- tableView.register (cellType : NibBasedCustomCell.self ) // This will register using NibBasedCustomCell.xib
207+ // This will register using the class (via `register(AnyClass?, forCellReuseIdentifier: String)`)
208+ // because the CodeBasedCustomCell type conforms to Reusable, but not NibLoadable (nor the NibReusable typealias)
209+ tableView.register (cellType : CodeBasedCustomCell.self )
210+ // This will register using NibBasedCustomCell.xib (via `register(UINib?, forCellReuseIdentifier: String)`)
211+ // because the NibBasedCustomCell type conforms to NibLoadable (via the NibReusable typealias)
212+ tableView.register (cellType : NibBasedCustomCell.self )
209213 }
210214}
211215```
0 commit comments