2018-05-24 18:14:01 +00:00
|
|
|
//
|
2018-09-06 05:42:23 +00:00
|
|
|
// Copyright © 2018 WireGuard LLC. All rights reserved.
|
2018-05-24 18:14:01 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
extension UITableView {
|
|
|
|
|
|
|
|
func register<T: Identifyable>(type: T.Type, prefix: String = "") where T: UITableViewCell {
|
|
|
|
register(type, forCellReuseIdentifier: prefix + type.identifier)
|
|
|
|
}
|
|
|
|
|
|
|
|
func dequeueReusableCell<T: Identifyable>(type: T.Type, for indexPath: IndexPath, prefix: String = "") -> T where T: UITableViewCell {
|
|
|
|
return dequeueReusableCell(withIdentifier: prefix + type.identifier, for: indexPath) as! T // swiftlint:disable:this force_cast
|
|
|
|
}
|
|
|
|
|
|
|
|
func registerNib<T: Identifyable>(type: T.Type, prefix: String = "") where T: UITableViewCell {
|
|
|
|
let nib = UINib(nibName: prefix + type.identifier, bundle: nil)
|
|
|
|
register(nib, forCellReuseIdentifier: prefix + type.identifier)
|
|
|
|
}
|
|
|
|
|
|
|
|
func registerNib<T: Identifyable>(type: T.Type, prefix: String = "") where T: UITableViewHeaderFooterView {
|
|
|
|
let nib = UINib(nibName: prefix + type.identifier, bundle: nil)
|
|
|
|
register(nib, forHeaderFooterViewReuseIdentifier: prefix + type.identifier)
|
|
|
|
}
|
|
|
|
|
|
|
|
func dequeueReusableHeaderFooterView<T: Identifyable>(type: T.Type, prefix: String = "") -> T where T: UITableViewHeaderFooterView {
|
|
|
|
return dequeueReusableHeaderFooterView(withIdentifier: prefix + type.identifier) as! T // swiftlint:disable:this force_cast
|
|
|
|
}
|
|
|
|
}
|