So I have a string called cellNumString that I created in the .h of my DetailViewController. In my HistoryTableViewController.m I have a prepareForSegue method in which I set the string to anything. For now I have this:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"Push"]) {
HistoryDetailsViewController *detailVC = (HistoryDetailsViewController*)segue.destinationViewController;
[detailVC setCellNumString:@" cell number"];
}
}
All I want is the @"cell number" part to be changed to cell.textlabel.text. But I can't use cell. How would I be able to get the value of cell.textlabel.text and use it as my string that I pass to the next view?
All help is appreciated, thanks.
If the segue is on the cell, you can use this answer https://stackoverflow.com/a/13989915/1835155
You can get also get the selected cell using:
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:selectedIndexPath];
NSLog(@"%@", cell.textLabel.text);