0

Can we Serialize the iPhone Navigation controller's stack to save the state? Is it allowed by Apple?

PgmFreek
  • 6,374
  • 3
  • 36
  • 47

2 Answers2

1

Saving the stack is as easy as reading the list of controllers pushed to the navigation controller and serializing them:

NSArray *myStack = [self.navigationController viewControllers]

I can't remember explicit guidelines from Apple that require developers not to do such a thing.

marzapower
  • 5,531
  • 7
  • 38
  • 76
0

can you give us more hint, why you want to do that? Is this for saving the user selection in the navigation controller? If I were you, I would save the class name by doing

[[myControllerObj class] description]

and save it somewhere like NSUserDefault, later if you want to push it again to stack then you need

NSString* className = @"MyControllerClass";
MyControllerClass* obj = (MyControllerClass*) [[NSClassFromString(className) alloc];
[myNavigation pushViewController: obj];

hope helps

:)

kororo
  • 1,972
  • 15
  • 26