It's the first time I use static cells in a table view and I just can't get them to show.
I have two sections (grouped) with two and three cells in each one respectively. The cells are static (custom) and all carry one label and one textfield:

I have created IBOutlets for each textfield, and for each cell in my view controller:

I have made the link between storyboard -> view controller where the outlets reside:

I have also set datasource & delegate on UITableView:

Since these are static cells, I am not using dynamic cell-related methods, e.g.tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath). Instead, I try to reference each textfield and cell via their outlets. My problem is that I keep getting a nil value returned for all the outlets. I tried referencing them in viewDidLoad, viewWillAppear and viewDidAppear but the result is always nil:

I programmatically instantiate the UIViewController via the use of a cocoa menu control:

What on earth am I missing? Any clues?
The problem is actually obvious. It's like you have not instantiated it. That's why it's all nil and you can't use it. Since you are using Nib file, you will need to have a way to load the Nib file and then reference it. When you are accessing this UIViewController from Storyboard, the system will take care this for you. What I am suspecting is, you programmatically create this UIViewController.
From another prospective, tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) is not for dynamic cells only. You can pass in the total number of your static cells and you can still use this method to perform the operation you want.
The problem was that I wasn't instantiating the UIViewController from the Storyboard.
Before (all outlets were nil):

After (worked):

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With