I have an array of objects that have multiple instance variables (name, address, number, etc). I also have a UITableViewController whose table view is populated with the name variable of each of these objects.
I have also created a DetailViewController that should display the rest of the information held by these objects when that objects' designated cell is selected with tableView:didSelectRowAtIndexPath:. The problem is, these cells only have references to the cell's objects' name variable.
How should I go about fixing this problem? Would I need to subclass the cell so that I could give each cell a reference to the entire object? or is there an easier way?
This is my current tableView:cellForRowAtIndexPath: method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if(!cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
cell.textLabel.text = [[listings objectAtIndex:indexPath.row] objectForKey:@"listingName"];
return cell;
}
update: it just occured to me that I could grab the row number from indexPath and grab the designated object from the array. Would this be more viable?