views:

45

answers:

2

I want to add the content of the cell of tableview in other view when i click on the tableview cell , how can i pass the values of the cell to other view.

A: 

In your table view delegate (by default, it's the table view controller) implement the following method:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

Use indexPath as you did in -tableView:cellForRowAtIndexPath: to get the values you need. To avoid unexpected behavior you should extract the values from your model rather than the cell.

Costique
+1  A: 

If you want use the text of a cellview for example you can do that in your UITableViewDelegate (or your UITableViewController):

// Tells the delegate that the specified row is now deselected.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     UITableViewCell *targetCell = [tableView cellForRowAtIndexPath:indexPath];
     NSString *contentCell = [targetCell textLabel];

     // Do something with the contentCell
}
Yannick L.