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

bug:sometime store property failure #23

Closed
yangyangyyluck opened this issue Jul 11, 2015 · 4 comments
Closed

bug:sometime store property failure #23

yangyangyyluck opened this issue Jul 11, 2015 · 4 comments

Comments

@yangyangyyluck
Copy link

Hi. needs help.
I find sometime store property failure.
my category GVUserDefaults (YOSProperties) has property like this:

@Property (nonatomic, weak) NSString *currentLoginID;

when network request success. I save userId in success block:
[GVUserDefaults standardUserDefaults].currentLoginID = model.ID;
It work this time. I can get data from [GVUserDefaults standardUserDefaults].currentLoginID
But reopen my app. It doesn't work. [GVUserDefaults standardUserDefaults].currentLoginID return nil

I replace
[GVUserDefaults standardUserDefaults].currentLoginID = model.ID;
to
[GVUserDefaults standardUserDefaults].currentLoginID = model.ID;
[[NSUserDefaults standardUserDefaults] synchronize];

It works all the time.
thinks.

@kevinrenskers
Copy link
Contributor

When using GVUserDefaults you also need to make sure to synchronize NSUserDefaults, or your changes might not be saved before you quit your app.

On 11 Jul 2015, at 11:02, yangyangyyluck notifications@github.com wrote:

Hi. needs help.
I find sometime store property failure.
my category GVUserDefaults (YOSProperties) has property like this:

@Property (nonatomic, weak) NSString *currentLoginID;

when network request success. I save userId in success block:
[GVUserDefaults standardUserDefaults].currentLoginID = model.ID;
It work this time. I can get data from [GVUserDefaults standardUserDefaults].currentLoginID
But reopen my app. It doesn't work. [GVUserDefaults standardUserDefaults].currentLoginID return nil

I replace
[GVUserDefaults standardUserDefaults].currentLoginID = model.ID;
to
[GVUserDefaults standardUserDefaults].currentLoginID = model.ID;
[[NSUserDefaults standardUserDefaults] synchronize];

It works all the time.
thinks.


Reply to this email directly or view it on GitHub.

@HYAdonisCoding
Copy link

how to synchronize in project?

@kevinrenskers
Copy link
Contributor

[[NSUserDefaults standardUserDefaults] synchronize]

@wonin
Copy link

wonin commented Nov 5, 2017

How to save object?

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

No branches or pull requests

4 participants