- Create new class extending UITableViewCell with xib
- In ViewController register nib for this class
DirectionViewCell.swift
class DirectionViewCell: UITableViewCell{
@IBOutlet var stopNameLabel: UILabel!
@IBOutlet var tagLabel: UILabel!
@IBOutlet private var headerView: UIView!
static let identifier = "DirectionCell"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
print(tagLabel) //If you do everything correct then this line shouldn't tchrow nil exception
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
TableViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let nib = UINib(nibName: "DirectionViewCell", bundle: nil)
self.tableView.registerNib(nib, forCellReuseIdentifier: DirectionViewCell.identifier)
}