Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: implement data_store and missing life cycle callbacks #1947

Merged
merged 4 commits into from Feb 13, 2016

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Feb 12, 2016

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.

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
@xymus
Copy link
Contributor Author

xymus commented Feb 12, 2016

test osx please

@xymus xymus changed the title iOS: implement data_store using NSUserDefaults and implement missing life cycle hooks iOS: implement data_store and missing life cycle callbacks Feb 12, 2016
@privat
Copy link
Member

privat commented Feb 12, 2016

+1

privat added a commit that referenced this pull request Feb 12, 2016
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>
@privat privat merged commit 298a7aa into nitlang:master Feb 13, 2016
@xymus xymus deleted the ios-data-store branch November 15, 2016 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants