NSIndexPath Archives

How to create an NSIndexPath and specify its components

On occasion we need to create an NSIndexPath manually, with components we specify (such as a row or a section). There’s a method for that: indexPath:forItem:inSection. Here’s how you create an indexPath for row 0, section 0: NSIndexPath *indexPath = [[NSIndexPath alloc]init]; indexPath = [NSIndexPath indexPathForItem:0 inSection:0]; The method takes two integers. You can even […]

How to pass an Index Path to another table

Say you have a central array somewhere and would like display this in more detail via two table view controllers. Instead of passing only the relevant information, you want to pass the entire index path from table1 to table2 and beyond. You can pass data in the prepareForSegue:sender method and let the Storyboard to the […]