This is probably something really simple to achieve, but I am new to programming for iOS and I seem to be stuck.
So, basically, I have a tabbed application. I decided that I wanted a navigation bar, in addition to the tab bar. To do this, I put the tab bar controller and then I added my view controllers and embedded in a navigation controller for each view controller, which is then connected to the tab bar.
My hierarchy in the storyboard looks somewhat like this:
- View Controller
- Tab Bar Controller
- Navigation Controller
- View Controller
- Navigation Controller
- View Controller
- Navigation Controller
- Tab Bar Controller
The part where I am stuck here, is when attempting to pass data from the first View Controller and to any of the other View Controllers. Before adding in the navigation controllers, I was using the prepareForSegue method to pass the data, like so:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"logged"])
{
UITabBarController *tabar=segue.destinationViewController;
SecondViewController *svc=[tabar.viewControllers objectAtIndex:1];
svc.groupArray = [(NSArray*)sender objectAtIndex:0];
svc.userArray = [(NSArray*)sender objectAtIndex:1];
svc.taskArray = [(NSMutableArray*)sender objectAtIndex:2];
svc.selfArray = [(NSMutableArray*)sender objectAtIndex:3];
[tabar setSelectedIndex:1];
}
}
As you can see, I was passing the data to my second view controller and set the tab bar index to 1 using the performSegueWithIdentifier method, since I wanted the second page to open. All of this was working just fine, until I introduced the Navigation Controllers to my code, since I want navigation bars. That's when everything pretty much broke. If I try to run the code as is, the application crashes with the following output in the console:
[UINavigationController setGroupArray:]: unrecognized selector sent to instance 0x7ffa6acec620
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setGroupArray:]: unrecognized selector sent to instance 0x7ffa6acec620'
I've tried messing around with the code a bit, but nothing seems to work really. I am just very confused, and maybe a hint in the right direction would help me out a bit.