Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Ryan Coughlin
Ryan Coughlin
1,677 Points

Performing a segue with a UITabBar

I am trying to search for a some resources on performing a segue between tabs using a UITabBar controller. I cant find anything directly related to this. Only segues between 2 view controllers (without a UITabBar).

Any ideas on how to do this? Essentially I am trying to pass a NSDictionary to my second tab in my UITabBar



3 Answers

Tab bar or tool bar? Tool bar goes with navigation controller and tab bar goes with tab bar controller.

If it's toolbar, simply link an IBAction outlet and call performSegue:

Otherwise, you just have to set it up in storyboard (or programmatically if you feel ambitious)

Ryan Coughlin
Ryan Coughlin
1,677 Points

UITabBar has the UITabBarController (should have rewrote it above).

If it was a UINavigationBar I would create an IBAction (the part im confused on is creating it with UITabBarController. I dont see how I would create the segue ID to each tab on the bar bar vs making a button -> segue -> view.

UITabBarControler has 2 tabs - these 2 views are the only views within my app.

In short:

"A user will land on Tab 1 and when a user taps Tab 2 --> ---perform segue here to send data to this view---".


Ryan Coughlin
Ryan Coughlin
1,677 Points

Solved this issue with creating a Singleton an calling that method where I needed to access that model:

+(TideModel*)tideSingleton {

    static TideModel* tideSingleton;
            tideSingleton = [TideModel new];

    return tideSingleton;

Example of calling it here:

[TideModel tideSingleton].tideDic = [[NSDictionary alloc] initWithDictionary:json];