Vipin
Vipin

Reputation: 4728

how can i get a row text from UITable View ? or(NSIndexPath)

I have

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}

Can I get the row appended string from it?

If yes,tell me the way to get it?

Upvotes: 0

Views: 184

Answers (2)

jaminguy
jaminguy

Reputation: 25930

If you are trying to get the text out of the cells textLabel you can do so like this:

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *text = cell.textLabel.text;

Upvotes: 0

PeyloW
PeyloW

Reputation: 36752

You can use [UITableView cellForRowAtIndexPath:] to get the UITableViewCell that is backing a particular view.

Do note that this method will return nil if the row is not visible on screen. This is because UIKit strongly encourages you to NOT keep state in views.

Instead you should fetch the needed string from from your domain model object as needed, just as you do when you populate the table view.

Upvotes: 1

Related Questions