8

I have a UIViewController with an outlet for a tableView

@IBOutlet weak var tableView: UITableView!

When I try to access the tableView variable in viewDidload it's throwing an error saying tableView is nil.

Everything seems to be set up in the interface builder. The class for File's Owner is set to my custom class and the tableView outlet is set as well. What could be going wrong here, why is tableView variable still nil even inside viewDidLoad?

1
  • Make sure the outlet is connected to your tableView.
    – Leo Dabus
    Apr 12, 2015 at 1:49

1 Answer 1

4

Did you type out that outlet code without creating a link?

If you did that would be your problem. Go back to your Storyboard, switch to assistant editor mode and CTRL + Drag from the UITableView to @IBOutlet weak var tableView: UITableView!

Ensure you're got a FILLED IN circle to the left of your var similar to this. Filled in circle

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.