UISearchController Tutorial: Getting Started

@mattharg if you have an array of arrays Iโ€™m assuming each element in your outer array is an array of items for a given section.

For example, if you array looks like this:

let data = [
      [1,2,3],
      [4,5,6],
      [7,8,9]
    ]

you can just return the size of the โ€˜dataโ€™ array in -[UITableViewDataSource numberOfSectionsInTableView:], by calling data.count.

In -[UITableViewDataSource tableView:numberOfRowsInSection:], you can use data[section].count to get the number of rows.

Then finally in -[UITableViewDataSource tableView:cellForRowAtIndexPath:] use data[indexPath.section][indexPath.row].

If you need more help, check out our UITableView tutorial: https://www.raywenderlich.com/68072/video-tutorial-table-views-multiple-sections

1 Like