I'm new to Swift/iOS development.
I have a UITableView
in my storyboard
that I want to populate with some data. In my attempt to do so, I created a class that inherits from UITableViewController
. The implementation is not yet complete, but my understanding is that by inheriting from this class I can provide an IBOutlet
to both dataSource
and delegate
.
When I try to drag the outlet into the source file, I don't get the insertion point that I got when I tested this before. See image below:
What do I have to do to define this class as the handler for the UITableView
?
Datasource methods are used to generate tableView cells,header and footer before they are displaying.. Delegate methods provide information about these cells, header and footer along with other user action handlers like cell selection and edit..
A data source is like a delegate except that, instead of being delegated control of the user interface, it is delegated control of data. A data source is an outlet held by NSView and UIView objects such as table views and outline views that require a source from which to populate their rows of visible data.
Methods for managing selections, configuring section headers and footers, deleting and reordering cells, and performing other actions in a table view.
The data source is generally the list of data that is supplied to the table view. The table views data source methods then iterate on this list and instantiate cells. Table view data sourced methods. There are a lot of different ways to configure your datasource for the table view.
Set your viewController to inherit from UIViewController
, not from UITableViewController
(It seems like your IB is set up like that).
Do not forget to set your class to ZeroconfTableController
on the interface builder.
Than, you will be able to set the delegate
and datasource
. NOTE: the delegate
and the datasource
will not create IBOutlet
s.
Assign the delegate
and the dataSource
the following way:
Also make sure, your viewController conforms to the protocols.
class ZeroconfTableController: UIViewController, UITableViewDataSource, UITableViewDelegate {
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