I have a UINavigationController that contians a UITableView with some UITextFields for the user to input data. When the user clicks on a UIBarButtonItem I save the data in the textfields to an object in my appDelegate that can hold this data. Then I push a new TableView into my UINavigationController. This new TableView uses the data in the object in appDelegate and list it for the user. Now to my problem.
The first time I click UIBarButtonItem to save the data it view the new TableView but in some strange way it doesn't get the data from the textfields. If I then uses the backbutton and then click UIBarButtonItem again the TableView shows up with the right data. I have been trying to figure this out, but can't. What can I be doing wrong?
Please help me out!
The code for saving my textfield-data to the object in appDelegate and push the new viewcontroller:
Code:
Profile *profile = [[Profile alloc] init];
[profile seValue1:textfield1.text];
[profile setValue2:textfield2.text];
TestAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
delegate.profile = profile;
[profile release];
MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
[[delegate navigationController] pushViewController: myViewController animated:YES];
[myViewController release];
The code that I use in "MyViewController" in the medhod "cellForRowAtIndexPath" to set the text for a cell:
Code:
cell.text = [delegate.profile value1]