Reputation: 28905
I have an iPhone application that does an action. Let's call it X. I'd like to have a pop up that asks the user if they want to rate my application after they have performed action X ten times. How can I keep track of this? Meaning, if they close the application the value will still be available. Do I need to keep a text file and update the value and write to a file each time or is there an easier way?
Upvotes: 0
Views: 94
Reputation: 6448
Another option is, use SQLite3 which is already included in iOS SDK. This works for people who are more familiar with SQL than Cocoa.
Upvotes: 0
Reputation: 20236
Why not just use L0SolicitReview. It does this, only a little bit different (still in line with what you described, just a few extra constraints). Best of all, it's done for you.
Upvotes: 2
Reputation: 8412
Use NSUserDefaults
.
You can do something like this to retrieve the value:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
int timesOpened = [defaults integerForKey:@"timesOpened"];
To save a value you do:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
int timesOpened = [defaults integerForKey:@"timesOpened"];
[defaults setInteger:(timesOpened + 1) forKey:@"timesOpened"];
[defaults synchronize];
See here for more information
Upvotes: 2