Search code examples
iphonexcodeuitableviewnsmutablearraypushviewcontroller

Cell Specific data on pushViewController


I have an NSMutableArray which does some processing and eventually has several objects although the exact number of objects cannot be predefined.

The objects from this NSMutableArray are then displayed on a UITableView, with each cell representing an object in the NSMutableArray..

What i want to do is simple. i want to select a specific cell and then be sent to a new view which has data specific to that object that is in the array. i have read about pushViewController and it seems like it would be the way to this, however in the view that gets pushed when a cell is selected, i want there to be a simple textbox (that the user can edit) that has data specific to that cell/object..

As i cant make any nib files for the pushViewController (because the data in the array is not the same every time), what can i do to:

  1. Push cell specific viewcontroller.
  2. allow user to edit this textbox.
  3. save textbox data and somehow connect to cell/object from nsmutablearray.
  4. when pushviewcontroller is called, cell/object specific data is loaded from somewhere.

Solution

  • You could, for example, create a property on your child view controller and retrieve the item from the parent view. I assume that you use something like a UITableView as the parent, so you can get the index for the selected item with the indexPathForSelectedRow message.