How can I reference the cell object that was clicked inside the didSelectRowAtIndexPath:(NSIndexPath *)indexPath method?
I have a UISplitViewController, and in the MasterView I have a table, with cells where cell.tag = a primary key from a sqlite database (i.e. table is populated from db). I’m able to capture the click event in the above method, but I can’t see how I can pass the cell object in, or how I can otherwise reference it to get at cell.tag. Ultimately, the goal is to pass that id to the detail view via the Master/Detail delegate, and then load data into the DetailView based on the id that comes in from the Master.
Any tips are appreciated!
Edit:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = NSLocalizedString(@"Detail", @"Detail");
Entry *entry = [self.entries objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[NSString stringWithFormat:@"%@",entry.title]];
cell.tag = entry.entryID;
return cell;
}
Because you already have an array of entries, you can also write as follows.
I think this is preferred way than cellForRowAtIndexPath: because