Reputation: 495
I am having a very frustrating issue from a very simple situation. I just want to connect and populate a UITableView from the Storyboard. Below is a picture of my situation.
As you can see, I just have a normal UITableView in my Storyboard, with a normal UITableViewCell set up as a prototype. The prototype cell has a Cell Identifier and the UITableView is properly hooked up to the IBOutlet in the UIViewController class. The UIViewController is assigned to be my UIViewController subclass in the Storyboard. Yet, the UITableView is nil in viewDidLoad(), and it is nil everywhere outside of viewDidLoad(), it is always nil. I have redone this three times now. I have restarted XCode, and I have restarted my computer. Is there something I am missing?
EDIT: The solution - Don't load the view controller programmatically in the app delegate... load from the Storyboard. Facepalm.
Upvotes: 3
Views: 2198
Reputation: 21144
Override the setter for tableView to check if that is really working.
class MyController: UIViewController {
@IBOutlet var beaconTableView: UITableView! {
didSet {
print("tableView is set")
}
}
.........
}
This will help you debug further about it. If the setter is not called at all. Remove the table from storyboard completely. Add a new one and create IBOutlet connection again. See if that works !
Upvotes: 4