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 3966418
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:35:54+00:00 2026-05-20T03:35:54+00:00

I have one single MainViewController which has of course it’s one main UIView. I

  • 0

I have one single MainViewController which has of course it’s one main UIView. I have this main view comprised of many different subviews.

Some of these subviews have their very own ViewController.

Lets say the MAIN view (whose delegate is primarily MainViewController) has a container which loads another UIView that uses a separate UIViewController- SecondaryViewController as the delegate for most it’s actions.

This container view is of course loaded in MainViewController via

MyContainerViewController *myContainerController = 
         [[MyContainerViewController alloc] ...]; 
[self addSubView: myContainerController.view];

the controller for myContainerController.view though is MyContainerViewController. How inside this controller do I access MainViewController properties? Specifically I need to access MainViewController’s – self.navigationController property to push a new ViewController? 🙂

Does this make any sense? I assume there’s going to be casting of some sort involved since it seems I need to somehow retain a reference to MainViewController inside SecondaryViewController?

  • 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-20T03:35:55+00:00Added an answer on May 20, 2026 at 3:35 am

    It doesn’t make sense to push a new ViewController from the SecondaryViewController in the MainViewController.
    This screws up the design of the code. A child object will access its parents method to call a method. By other words: bad code.
    Make a delegate call from the SecondaryViewController to the MainViewController that it state has changed. Then the MainViewController can decide to do with the call and the SecondaryViewController will not know anything about the implementation of the MainViewController.

    So:
    Make a protocol in SecondaryViewController.
    Let the MainViewController be SecondaryViewController’s delegate.
    Implement the delegate method in MainViewController which pushes the new ViewController.

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

Sidebar

Related Questions

Should we have one single repository for all the company, which contains many development
i have one single class for margin and i am using this class to
I have two different modules that need access to a single file (One will
I have a single Magento install running two different websites. One sells ebooks and
I would like to have one single file in my /bin which would listen
Example: I have one persistent store coordinator which uses one single persistent store. Now
i am new to android.i have one single activity with main.xml file. Now, i
I have one file which will contain the data for many smaller files inside
I have one single repository. Suppose I have LibraryX which I share across projects.
I have merged multiple jpeg files into one single .bin file. ..... ......... while(true){

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.