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

  • Home
  • SEARCH
  • 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 3231286
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:01:39+00:00 2026-05-17T17:01:39+00:00

EDIT: I seem to have found something that’s helped. I retained the ivar stack

  • 0

EDIT: I seem to have found something that’s helped. I retained the ivar “stack” and now it seems to be working

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.

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?

//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] > 1) {
           self.navigationController.viewControllers = stack;
           [stack release];  //retained earlier
   }
   return YES;

}

  • 1 1 Answer
  • 2 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-17T17:01:39+00:00Added an answer on May 17, 2026 at 5:01 pm

    I had to -retain the viewController stack after loading it from disk. Evidently if you don’t immediately assign the data to a retained property it vanishes.

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

Sidebar

Related Questions

I've been messing around with different forms and tables, now I need something that
I have been working on an Android app using Phonegap and now would like
EDIT: See my answer below--> I am wanting to have a view that when
Ok, what I have going on is a textbox that has been filled with
I'm seriously stuck here with something obvious. I have an application that communicates with
This might be a duplicate question as I have found a few that are
The odd task that I have been given is to serialize a LARGE object
There doesn't seem to be (to my knowledge) an API to edit Google Docs
I am a Symfony2 newbie running into problems with edit-forms and doctrine. I seem
EDIT: I was an idiot. I simply had an image that was vertically long,

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.