title: NSCoding Serialization of iPhone NavigationController stack
body: <p>EDIT:  I seem to have found something that's helped.  I retained the ivar "stack" and now it seems to be working</p>
  
  <p>I have been serializing several custom NSObject classes without issue.  Now I'd like to serialize my NavigationController stack.  Each viewController only needs a couple of properties saved in order to rebuild the navigation tree.  I've implemented the NSCoding protocol in the viewControllers, and successfully coded them to NSData and saved to disk.</p>
  
  <p>When I attempt to load the stack, the resulting array has the correct number of objects, but I keep getting EXC_BAD_ACCESS errors when I try to set the viewController array.  Am I just going about this the wrong way?</p>
  
  <pre><code>//AppDelegate.m
  -(void) loadDataFromDisk {
     NSString *libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
     NSString *programDataPath = [libraryPath stringByAppendingPathComponent:@"programData.dat"];
     NSData *programData = [[NSData alloc] initWithContentsOfFile:programDataPath];
     NSKeyedUnarchiver *decoder = [[NSKeyedUnarchiver alloc] initForReadingWithData:programData];
     //stack is a mutable array declared in header
     //stack = [decoder decodeObjectForKey:@"stack"];
         stack = [[decoder decodeObjectForKey:@"stack"]retain]; //retain fixes? Seems to work
     [decoder release];
  }
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
     // Override point for customization after app launch    
     [window addSubview:[navigationController view]];
     [window makeKeyAndVisible];
     NSLog(@"%@",self.navigationController.viewControllers);
     if ([stack count] &gt; 1) {
             self.navigationController.viewControllers = stack;
             [stack release];  //retained earlier
     }
     return YES;
  </code></pre>
  
  <p>}</p>