Merge: iOS: implement data_store and missing life cycle callbacks
authorJean Privat <jean@pryen.org>
Fri, 12 Feb 2016 20:47:52 +0000 (15:47 -0500)
committerJean Privat <jean@pryen.org>
Fri, 12 Feb 2016 20:47:52 +0000 (15:47 -0500)
commitacc18ca59e1d55b2d04029005b15796575830a72
treef9180af27d0ea501cc85bcde003f96da8b6b5109
parent19c0a20b6c7dfd2fe061dfeda1b2c1f54e85d4de
parent298a7aaa84dbe584c21f3a26d3d84fdad1a46d62
Merge: iOS: implement data_store and missing life cycle callbacks

Implement the main missing features of _app.nit_ on iOS: `data_store` and life-cycle hooks (like `on_save_state`). These changes can be seen on the calculator app, as it preserves its context using the `data_store`.

`data_store` is implemented with `NSUserDefaults` to store objects sertialized to Json. It is very similar to Android's implementation using shared preferences. This may be a bit limited as it is not meant to hold large strings, and some data objects (like game saves) should instead be saved to a file.

This PR also implements all life-cycle callbacks in iOS, until now only `on_create` was implemented. We may have to update _app.nit_ life-cycle to fit better with the life-cycle of iOS, the states between a running app and a fully stopped app are different between iOS and Android. I'm thinking of removing the two callbacks on_start/on_stop and keep only the more general callbacks on_create/on_destroy and on_resume/on_pause, and the services on_restore_state/on_save_state.

Pull-Request: #1947
Reviewed-by: Jean Privat <jean@pryen.org>