I have a table view with a few items (all text). When the user clicks the row I want that text in that cell to be added to an array.
How Do I grab the text out of the cell?
I already Have:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
Is there a simple line I can use to grab the text out the cell that the user clicks?
Use UITableView
's cellForRowAtIndexPath:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *cellText = cell.textLabel.text;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With