I am able to get the text value of a cell like this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger *row = [indexPath row];
// NOW GET THE NAME AND ID FROM THAT ROW
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = cell.textLabel.text;
NSLog(cellText);
}
but I need to be able to get the id of that item, or at least use the row to get the item from the array.
Here is how I get the array for the UITableView populated:
@synthesize items_array;
and later:
items_array = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
[self.itemList reloadData];
and the array has JSON which has for every item, fields like item_id, and item_name
So when the user clicks on an item from the list, how can I get the id field?
Thanks!
1 Answer