Question

I am having this error on Xcode, any ideas please ?

[[NSUserDefaults standardUserDefaults] setInteger: *(highScore) forKey: @"retry"];

I want to save highScore in the defaults database, retry is a button

Was it helpful?

Solution

There is no reason for your integer to be stored as a pointer. Change your property to:

@property (nonatomic, assign) NSInteger highScore;

you also don't need to synthesise it, so remove that (the compiler does it for you, and it does a better job).

Then change your user defaults code to:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setInteger:highScore forKey:@"retry"];
[defaults synchronize];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top