You can use NSUserDefaults for this.
To save it:
NSInteger myValue = ...;
To read this:
NSInteger myValue = [[NSUserDefaults standardUserDefaults] integerForKey:key];
If the previous value was not saved, the return value will be 0.
Add this to your WillTerminate app:
[[NSUserDefaults standardUserDefaults] synchronize];
source share