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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:25:14+00:00 2026-06-15T21:25:14+00:00

In the application I’m currently working on, there’s a case where I have 2

  • 0

In the application I’m currently working on, there’s a case where I have 2 screens for a set of data: one is a list and one is a map. Each screen has its own view controller. The default screen is the list view, so that view controller loads first. But the other map screen view controller is also loaded and set up (as it encapsulates some geographic map-related data that the list screen view controller uses), even though the map screen is not visible yet.

I don’t want the map screen view controller’s nib and views to be loaded and initialized until the user switches to that screen, however.

Is there anything wrong with overriding the view property accessor within the map screen view controller as in the code below, and lazily loading/instantiating the nib? (The view property is not accessed until the map screen is about to be displayed, right before the map screen view controller’s viewDidLoad method gets called.) I’ve tested that this works well, but I’ve never seen it done this way.

- (UIView *)view {
    if (!_view) {
        UINib *nib = [UINib nibWithNibName:@"MyNibName" bundle:nil];
        [nib instantiateWithOwner:self options:nil];
    }
    return _view;
}
  • 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-06-15T21:25:15+00:00Added an answer on June 15, 2026 at 9:25 pm

    Figured out a better answer to this.

    The code I’m working with isn’t actually my own, and I hadn’t noticed that the map screen’s view controller wasn’t actually a subclass of UIViewController, it was just subclassing NSObject (and adding its own view property).

    By changing the map screen’s view controller to actually inherit from UIViewController, and then using the designated initializer of initWithNibName:bundle:, the nib is by default lazily loaded/instantiated when the view property is accessed — just like I was doing.

    So, the answer to my question would be this: use the system frameworks and you won’t even run into these issues! 🙂 But it does seem to be the case that my code aligned with the actual best practice pattern; see Apple’s guidelines and recommendations here.

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

Sidebar

Related Questions

Application : I am working on one mid-large size application which will be used
My application requires an on-drive map as there will be no internet access during
Application use NHibernate. I Have object A that contains set of objects B. I
Application I develop requires several data sources (2 RDBMS and one file storage) to
Application, have a TextBlock and two Buttons, the text is displayed TextBlock by clicking
Application[temp] = 8; should set the value 8 to the key temp . However,
Application is running in my local system app.config file <add key=dbconn value=Data Source=(local);database=VTech;User ID=sa;Password=sa;
My application has one activity which starts two services but does not bind them.
Application stores configuration data in custom section of configuration file. This information is used
Application uses Entity Framework 4.1 with database first approach. I have in database a

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.