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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:43:55+00:00 2026-05-11T14:43:55+00:00

I have another question about restoring application state, on the iPhone. Simple data (like

  • 0

I have another question about restoring application state, on the iPhone. Simple data (like the selected tab) can be stored in NSUserDefaults, but it is not enough.

I want to restore the whole state, including the Navigation Controllers (go to the sub-sub-sub View Controller).

My problem is that my application is divided in several xib files, so at the beginning, all the View Controllers are not instantiated. Is there any way to ‘force’ the instanciation from a xib file ?

(I have no code under the hand, but I can try to write a small end if it is not clear)

Thanks a lot.

  • 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. 2026-05-11T14:43:56+00:00Added an answer on May 11, 2026 at 2:43 pm

    Calling [viewController view] will make sure that a given view controller’s XIB is loaded; once it is, you can use any of its other properties normally.

    Here’s what I tend to do:

    @class Record;  // some model object--I assume it has an integer record ID @class DetailViewController;  @interface RootViewController : UIViewController {     IBOutlet DetailViewController * detailController; }  - (void)restore; ... @end  @implementation RootViewController  // Note: all detailController showings--even ones from within  // RootViewController--should go through this method. - (void)showRecord:(Record*)record animated:(BOOL)animated {     [self view];    // ensures detailController is loaded      [[NSUserDefaults standardUserDefaults] setInteger:record.recordID                                                 forKey:@'record'];     detailController.record = record;      [self.navigationController pushViewController:detailController                                           animated:animated]; }  - (void)restore {     int recordID = [[NSUserDefaults standardUserDefaults] integerForKey:@'record'];      if(recordID) {         Record * record = [Record recordWithID:recordID];         [rootViewController showRecord:record animated:NO];         // If DetailViewController has its own state to restore, add this here:         // [detailController restore];     } } ... - (void)viewDidAppear:(BOOL)animated {     [[NSUserDefaults standardUserDefaults] removeObjectForKey:@'record']; } @end  @implementation MyAppDelegate  - (void)applicationDidFinishLaunching:(UIApplication*)application {     ...     [rootViewController restore];     ... } ... @end 

    Each level of the view hierarchy takes care of its own state saving, so the app controller doesn’t have to know about all the possible views and which orders they could be in.

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

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • 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 Does it work if you use CROSS APPLY instead of… May 11, 2026 at 11:32 pm
  • Editorial Team
    Editorial Team added an answer Not sure of the question but public class resultEventArgs<ObservableEntityCollection<T>> :… May 11, 2026 at 11:32 pm
  • Editorial Team
    Editorial Team added an answer You can do that. The problem is the inheritance modifier… May 11, 2026 at 11:32 pm

Related Questions

Report design, generation and maintenance isn't hard, but it is dull. We have a
Given two MS SQL databases which are known to have identical schemas, how should
Using Visual Studio 2008 / C# / VS Unit Testing. I have a very
I have, as best as I can manage, set up IIS (6.0), PHP (5.2.8)

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.