Jason
Jason

Reputation: 1067

IBOutlet not connecting in SWIFT

All,

I have this in swift

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

    @IBOutlet var tableView: UITableView!

So if i go in the storyboard, I should be able to see that, and I should be able to connect it like this :

enter image description here

So I should be able to go to 'New Referencing Outlet' and drag it on the view controller (yellow tab at the top) and I should see 'tableView' and connect it. This doesn't happen , I am confused why !

Upvotes: 1

Views: 1662

Answers (2)

Jazz Madahar
Jazz Madahar

Reputation: 41

Do no type following line in advance.

@IBOutlet var tableView: UITableView! // <-- this line

Instead, add a UIComponent in your storyboard first and then using "assistant editor" drag the connection link in your swift file.

enter image description here

Upvotes: 1

Jakub Truhl&#225;ř
Jakub Truhl&#225;ř

Reputation: 20710

On the picture you posted I can see you are looking for IBOutlet, but you selected the tableView not the whole controller.

Click on the white status bar (where yellow - controller and 2 oranges - responder and exit buttons are) then you will see your IBOutlet

Upvotes: 0

Related Questions