I've got a section of rows in a tableView (section 1) and I need to initialize an [NSIndexPath] array for all rows in that section.
I know I can count the number of rows in the section easily enough:
let rowsInSection = tableView.numberOfRowsInSection(1)
But that only gets me the row count, not the index paths.
What's the cleanest, most "Swift-like" way of retrieving the index paths?
An example of what I'm looking for:
func indexPathsForRowsInSection(section: Int) -> [NSIndexPath] {
// magic happens here
return indexPathsForRowsInSection
}
forloop to populate the array.forto loop the count of row, then declare indexPath directly likelet index = NSIndexPath(forItem: i, inSection: 0). i will be your item row