numberOfSections in Swift

For some reason my EntriesTableViewController was not getting the list of items from EntryViewController. I was at section # Listing Entries.

I realised that not deleting a pre-built function code was causing the issue. I had kept this function in the code :

    override func numberOfSections(in tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0

What does numberOfSections indicate ?

So with tableviews you can have sections and rows. An easy way to think of this, is to think about the iOS music player. If you look at a tableview of artist names, the sections represent letters in the alphabet. Then the rows are individual artists. Does that help?

1 Like