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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:33:54+00:00 2026-05-13T07:33:54+00:00

Given the section of an application which has a UINavigationController and 2 levels of

  • 0

Given the section of an application which has a UINavigationController and 2 levels of UITableViews (i.e. a row is selected on the root controller which pushes the second controller onto the navigation stack) I have the following questions:

1) There is a User object which is required by both controllers. What is the best way to communicate between the two controllers? I have seen a post on this site which mentions dependancy injection and that the root controller could pass the User object to the second level controller by:

@implementation SecondLevelViewController

-(void) initWithUser: (User *) user {
   // myUser is an instance variable
   myUser = user;
   [myUser retain];
}

In that example the second controller would seem to retain the User whereas I have seen other sources (e.g. the Stanford iPhone development course) which advocate the User being simply assigned, and not retained, in that situation (loose coupling).

I have also seen arguments for a form of delegation where an assigned id object would be used on the second controller (rather than a retained User instance variable as above).

It would be great if someone could clarify this position for me as I am extremely confused by the seemingly conflicting advice in this area. What is the best way for communication between view controllers?

2) My second question also relates to the structuring of the controllers. I have seen examples where the root controller (in the arrangement above) has an array of instantiated second level controllers. Is this normal in a professional application or would there be a significant memory impact for doing things this way (i.e. no lazy loading)? I assume the advantage of the array is a reduction of loading times for the second level controllers?

Thank you for any responses as I am trying to develop things properly rather than hack them together.

  • 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-13T07:33:55+00:00Added an answer on May 13, 2026 at 7:33 am

    1) “What is the best way for communication between view controllers?”

    There is no one “best” way. You can certainly pass a model object to the view controller on initialization. In that case, the controller should generally retain the model. Going with a delegate is a good option if you are writing a general view controller class with a focus on reusability (such as UITableViewController).

    2) “I have seen examples where the root controller (in the arrangement above) has an array of instantiated second level controllers. Is this normal in a professional application”

    Firstly, you should limit your posts on SO to one question per post. The memory impact of a view controller itself is usually quite low. It needs just a few hundred bytes for its instance variables. The memory-intensive part are the views themselves. And UIViewController’s view loading/unloading mechanism will take care to unload the memory-intensive view when needed (i.e. if it receives a memory warning and the view is currently not on screen). So as long as you implement viewDidLoad, viewDidUnload and didReceiveMemoryWarning correctly, I wouldn’t worry too much about memory consumption of an array of view controllers.

    UITabBarController holds an array of subcontrollers, too, so there is nothing wrong with that. What you should avoid, though, is for one controller to hold an entire hierarchy of subcontrollers (i.e. not only second-level, but also third-level etc.): not so much because of memory concerns than to avoid unnecessary coupling.

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

Sidebar

Ask A Question

Stats

  • Questions 254k
  • Answers 254k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer See example and references in python-imap-idle-with-imaplib2 (Wayback Machine snapshot). The… May 13, 2026 at 10:05 am
  • Editorial Team
    Editorial Team added an answer The Android Market doesn't make any provision for this currently.… May 13, 2026 at 10:05 am
  • Editorial Team
    Editorial Team added an answer This might be possible with pure HTML+CSS using anchors but… May 13, 2026 at 10:05 am

Related Questions

I'm writing applications that interoperate with a third-party application. This application exposes an API
I know a lot of question regarding VB6 migration have been asked, but I
Whenever a user reports an error such as System.Runtime.InteropServices.SEHException - External component has thrown
I am attempting to use ASIHttpRequest with the iPhone to get some information from
I have a UITableView with reorderable rows and I'm using the standard UITableViewCell.text property

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.