Did you ever want your app to open the last used document on startup? Well, that’s not too difficult on macOS. In your
NSDocumentController subclass you have the array of
recentDocumentURLs, and on startup you can try to open the first member if it exists.
But on iOS it’s a little bit more tricky. There is no such array as on macOS. So we have to mimic it by ourself.
This is a review of my post 2 years ago: UIDocumentBrowserViewController and External Storage
Some time ago I’ve ported the old and ancient strategy game „Empire“ from macOS to iOS. On macOS I decided to make the game document based. Since the game may last many hours (or even more), it is necessary to store the state of the game in some kind of document to continue it in a later session. On start-up of the game it tries to re-open the last used document. That’s quite easy with the
recentDocumentURLs array of the
But for iOS such a facility is missing. There is no such thing as a „UIDocumentController“ and the
UIDocumentBrowserViewController tells you nothing about recently opened or created documents. I wanted to make the iOS version of Empire document based as well to enable anytime switches between the iOS and macOS version of the game. That’s especially interesting, if the game document is stored on some external server (like iCloud).