I am trying to programmatically add UITableViewCells in swift and getting the following error message:
2016-05-10 21:58:41.961 appname[28802:2378292] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'myCell''
I have the following in my viewDidLoad
:
let myNib = UINib(nibName: "myCell", bundle: nil)
tableView.registerNib(myNib, forCellReuseIdentifier: "UITableViewCell")
and the following in func tableView
:
var cell:UITableViewCell! = tableView.dequeueReusableCellWithIdentifier("UITableViewCell", forIndexPath:indexPath)
print("setup cell")
if cell == nil{
print("cell == nib")
let cellnib = [NSBundle.mainBundle().loadNibNamed("myCell", owner:self, options: nil)]
cell = cellnib.first! as! UITableViewCell
}