I am trying to log data from the FirstView (one text field and one button) to SecondView (UiTableView) for example contacts list. I would like to briefly explain my code.
I have added a NavigationController with TabBar in the AppDelegate.m;
UINavigationController *pointer = [[UINavigationController alloc] init];
self.window.rootViewController = pointer;
[pointer setNavigationBarHidden:NO];
[pointer pushViewController:self.viewController animated:YES];
And I have used a [self.navigationController pushViewController:push animated:YES];
to push the data to the second screen but it always go to another NavigationController view as loop with BACK button, then I have used [self.navigationController popToRootViewControllerAnimated:YES];
which it does not pass the data to the another view. Unless I close the program completely an open it back again. So is there a way to push and pop at the same time? Or could you please show me another way?
Thanks in advance.
Note I have shared my code in this link; Mycode
You can try to create a singleton
class that manages this data. Then you just call the same singleton class throughout your code, it should keep the same state throughout the lifetime of your app.
Or, a simpler way is to Set up "myArray" as a property in your App Delegate.. Then, in your class' implementation file, do something like this:
UIApplicationDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.myArray = newArray;
this assumes myArray and newArray has been properly initialized.