0

I have a segue set from UITableViewController A to UITableViewController B. In the prepareForSegue, based on the list item selected, I want to retrive the associated NSManagedObjectID from an 'items' array (I am not using a fetched results controller yet). I will then send this ID to controller B so I can filter the list items to only those associated with the selected item.

I can get the indexPath of the selected list item using

[self.tableView indexPathForSelectedRow];

and my plan was to use this to find the corresponding item in my 'items' array. Presumably the indexPath has some kind of numerical attribute that corresponds to the index I should look up in my array?

a) Is there some attribute of the indexPath that will correlate to the index of the associated array object? It seems a bit unreliable, since I can't know how my array is filled (ordering etc). b) If so, how do I find the array item using the indexPath? c) Is there a better way to do all this (without using a fetched results controller)? I've read elsewhere that the NSManagedObjectID is a sensible thing to pass on to the second controller.

Ben Packard
  • 26,102
  • 25
  • 102
  • 183
  • ??? if _you_ don't know how the indices of your items map to the rows in your table view, then who _does_ or is supposed to? (Read: What does your `tableView:cellForRowAtIndexPath:` look like?) – danyowdee Jan 07 '12 at 15:45
  • Ok - so I found how to find the array item using the indexPath, but I guess I just wan't confident that relying on the order of each to retrieve the item was ok. – Ben Packard Jan 08 '12 at 05:36

0 Answers0