Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Calling <code>[viewController view]</code> will make sure that a given view controller's XIB is loaded; once it is, you can use any of its other properties normally.</p> <p>Here's what I tend to do:</p> <pre><code>@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 </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload