I want to populate a UITableView
with a list of paired Bluetooth devices but I'm unsure how to obtain the view object so I can populate it. Under Android each UI element is assigned a resource ID which is used to get an instance of a particular UI element but I'm not sure how this is done in iOS.
In my ViewController class I have this:
@IBOutlet weak var btListView: UITableView!
I'm looking to assign this variable to the Tableview instance on my main storyboard presumably within viewDidLoad().
Also, when I try to assign an outlet to the view by right clicking it in the storyboard the + options are there but nothing happens when I click New Referencing Outlet.
I'm looking to assign this variable to the Tableview instance on my main storyboard presumably within viewDidLoad().
You don't have to do anything in your code. Just connect the table view to the btListView
outlet in your storyboard, and you'll find that when viewDidLoad()
executes, btListView
will already refer to the table. That's really the nice thing about outlets... you connect them when you design your interface, and that connection is re-created for you when the objects in the storyboard scene are loaded.
To make the connection in the storyboard, find the relevant scene in your storyboard and look at the list of objects in it. Your view controller should be among those, and you can examine its list of outlets by control-clicking on the view controller. A list will pop up, and you can either drag from the little circle at the right of the btListView
outlet to the table, or you can control-drag from the table to the view controller and select the btListView
outlet when it pops up.