Saving and loading the navigation stack
NavigationPath
, besides .append()
and .removeLast()
, provides .count
and .isEmpty
properties, which you could use in order to control the stack programmatically. Basically, you can delete and create whatever you want on the stack, in however many levels as you please, and you can do it all programmatically.
So, you could come up with your own solution to save the stack programmatically or manipulate it in any way you want. One possible suggestion could be using a state machine pattern if you have a really complex navigation structure in mind.
But in order to make things even easier, NavigationPath
has a .codable
property, which allows you to convert to and from JSON format. You could send the path to a server, deep link a view of your app from a web service, and so on.
One of the many applications is storing the path so that when the app is suspended or terminated, it is restored when the app is started, so that the app has a persistent...