I am new to this. I have an application with a Tableview where when I pressed on a cell, it will navigate me to a DetailView. Now the problem is that I have a textField within the Detailview and I want to load the data that the user has keyed back to the detailTextLabel segment of the original cell after i press a save button.
How do I go about doing so? Below is what I have:
DetailViewController.m
//save button
-(IBAction) SendTextFieldtoViewController:(id)sender {
NSString *grabKeyedData = self.inputField.text;
ViewController *mainController =[self.storyboard instantiateViewControllerWithIndentfier:@"mainController"];
[mainController GrabbedKeyData: grabKeyedData];
}
ViewController.m
-(void) GrabbedKeyData:(NSString *)text{
grabData = text;
NSLog(@" data: %@",text);
[tableView reloadData];
}
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath {
.....
if(grabData == nil){
[[cell detailTextLabel] setText:@"no data"];
}else{
[[cell detailTextLabel] setText:grabData];
}
I have managed to pass the data to -(void) GrabbedKeyData and i can read the passed data from NSLog. But the table does not seems to update from it when i return back to the ViewController.