Passing data back from detailViewController to Uitableview
- by jsetting32
I am currently at the issue where I have a UITableviewCell that needs to be updated.
When the user presses on the uitableviewcell - THERES ONLY 1!!, the user is pushed to a UITABLEVIEWCONTROLLER where the user is allowed to select 1 of multiple cells with their own titles.
I need to get the clicked tableviewcells title and pass the value back to the parentviewcontroller and update the 1 tableviewcell's name to the one the user clicked in the pushed uitableivewcontroller.
Here is a picture of the parent viewcontroller...
And heres the picture of the pushed viewcontroller....
I was told earlier yesterday that delegation would be needed but I am unsure what to do at this point :/.
Heres some code I use in the parent viewcontroller...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
ProblemTypes *view = [[ProblemTypes alloc] init];
[self.navigationController pushViewController:view animated:YES];
}
I am also NOT USING storyboards, just a few xibs.
Also heres the code for the pushedviewcontroller to pop to the parent viewcontroller when a cell is selected...
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"Cell's text: %@",cell.textLabel.text);
[self.navigationController popViewControllerAnimated:YES];
}
Thank you guys!