I have CustomTableViewClass
in XIB, adding it to UITableView
like
class RestaurantsTableView: UITableView {
override func awakeFromNib() {
self.register(UINib(nibName: "RestaurantTableViewCell", bundle: nil), forCellReuseIdentifier: "restaurantCell")
}
}
and everything works fine, now I would like to use this CustomTableViewClass
as UIView
in some other UIViewController
, but I do not get how to properly override its init(coder aCoder: NSCoder)
function, cause I do not need one for UITableView
case and when I implement it like I do for other custom XIB views it crashes with nil
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
let _ = Bundle.main.loadNibNamed("RestaurantTableViewCell", owner: self, options: nil)?[0] as! UIView
}