Reputation:
I just want to get the value of a cell in the table view when i tap on it.. can any one help me in this.?
Thanks in Advance Shibin Moideen
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
appDelegate.courseName=[appDelegate.courses objectAtIndex:indexPath];
NSLog(@"%@",appDelegate.courseName);
DetailCourseViewController *detailController = [[DetailCourseViewController alloc]
initWithNibName:@"DetailCourseView" bundle:nil];
[self presentModalViewController:detailController animated:YES];
}
is that done in this way. also i need to store that value in a string which i declared in the app delegate.
Upvotes: 0
Views: 994
Reputation: 8090
You use the tableView:didSelectRowAtIndexPath:
delegate method and use the indexPath
to return the cell that was tapped.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"%@", cell);
}
Upvotes: 1