Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4266778
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:48:27+00:00 2026-05-21T06:48:27+00:00

I have a rootController and 5 contentControllers, each as its own class. I want

  • 0

I have a rootController and 5 contentControllers, each as its own class.

I want to be able to call the next content controller from the current content controller. For example, if I’m currently showing contentController1, I want a way to show contentController2.

It’d be ideal if I could add a short method to every controllers’ implementation file that passed the number of the controller to be called to the actual method that loads and shows the new controller.

For example:

@implementation ContentController1

- (int) loadNextController {
  //take the 1 from ContentController1, add 1 to it, and pass it somewhere else
}

Then somewhere else (the root controller? the app delegate?) add the following method that then loads and shows the contentController based on the int sent from the (int) loadNextController method:

-(void) loadNextController: (int) nextController {
//init and show controller
}

If you could show me the code and, more importantly, where it goes, I would really appreciate it.

Trevor

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:48:28+00:00Added an answer on May 21, 2026 at 6:48 am

    It’s not clear exactly how you want these view controllers to relate to each other. For example, you might want to push each one in turn onto a navigation controller’s stack, so that the user always has the option of going back through the previous view controllers. Or, you might have a requirement that says that the user has to go through the five controllers in succession without the option to go back, in which case you’d probably set the window’s rootViewController property to each controller when its time comes. Your decision will determine how you write the code that presents each controller’s view. Read View Controller Programming Guide for details.

    The design you describe above has each view controller deciding which view controller to present next. That’s often appropriate, especially where the view controllers form a hierarchy. From your description, though, it seems that it might be helpful to concentrate all the knowledge about the sequence in which controllers are presented in one object. Make that object the delegate of each controller, and have that object (possibly the application delegate) determine the order of the controllers. As an (untested) example, you might add this to your app delegate:

    -(void)application:(UIApplication*)app didFinishLaunchingWithOptions:(NSDictionary*)options
    {
        //...
        self.controllers = [NSArray arrayWithObjects:
                       [[[ViewControllerA alloc] initWithNibName:nil bundle:nil] autorelease],
                       [[[ViewControllerB alloc] initWithNibName:nil bundle:nil] autorelease],
                       //...
                       [[[ViewControllerN alloc] initWithNibName:nil bundle:nil] autorelease]];
    
        // Make self the delegate for each of the view controllers.
        [self.controllers setValue:self forKey:@"delegate"];
    
        [self.navigationController pushViewController:[self.controllers objectAtIndex:0] animated:NO];
    }
    
    -(void)viewControllerDidFinish:(UIViewController*)controller
    {
        NSUInteger index = [self.controllers indexOfObject:controller];
        NSUInteger nextIndex = index + 1;
    
        if (nextIndex < [self.controllers count]) {
            [self.navigationController pushViewController:[self.controllers objectAtIndex:nextIndex animated:YES];
        }
    }
    

    Then, whenever a view controller is ready to switch to the next controller, it can just call:

    [self.delegate viewControllerDidFinish:self];
    

    Again, the idea here is that the order of the view controllers in the array determines the order in which the controllers will be presented. I’ve used a nav controller here, but you don’t have to. Also, you’ll probably want to declare a protocol with your -viewControllerDidFinish:(UIViewController*)controller method, adopt that protocol in your app delegate (or whichever object manages the controllers), and have your controllers’ delegate properties specify that protocol. That’ll avoid any warnings about the delegate not implementing the method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scroll-view with a UIImage on top the UIImage has its own
So I have 2 tabs in tab bar controller. tab 1 is the rootController.
I have a project inwhich the root controller call multi viewcontrollers. What is the
I have a rootcontroller pushed on a UINavigationController . Inside that rootcontroller class, I
I have root view that presents navigation controller with content controller, this is how
I have a navigation-based app and say my root controller A causes a viewController
have written this little class, which generates a UUID every time an object of
I have a website and I want /22 Redirect to /user/22 etc and so
I have build a UITabBarController programmatically and populated its viewControllers property. When I run
If a user has location services on, I assign my RootController as its delegate:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.