Data persistence in iOS apps

Graham Samuel livfoss at mac.com
Thu Apr 19 09:01:48 EDT 2012


In LiveCode desktop apps, you can't put stuff in the mainstack of the app or its substacks and expect it to be there next time the program is run: there are often questions on this list about this kind of thing. The basic rule that prevents self-modifying programs in modern OSs means that the mainstack is essentially read-only, so saving of the main stack and its whole data tree is not allowed: the traditional solution is "put your data into a different stack which you open at the start of the program and save when it quits" (the Splash Screen method).

Now, what about iOS? As far as I understand the iOS app concept (which is not very well), the whole thing runs in the app's sandbox, and when the program quits or is suspended (same thing, in effect), the entire state of the app is recorded. If this is true, then you might think that when an app creates new cards in its main stack, then those cards will still be there when you restart the program. My experiments show that they aren't - this is not unexpected exactly, but it raises the question: what is kept in the sandbox - is it only stuff that has been deliberately saved in the 'documents' folder or whatever? Or is some other status information stored by the system and if so what? Can I know for example how many times my app has been launched on this device? I expect there is something about this deep in the XCode docs but I have not found it. Does anyone know?

Graham




More information about the use-livecode mailing list