NSUserDefaults: detecting nil
- by alJaree
I have some code in my classes to read from NSUserDefaults
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
score = [defs integerForKey:@"score"];
this causes a crash.
Im guessing it is because the score value is nil or doesnt exist.
How can I check if it is nil?
EDIT.
The following code causes a crash when storing to NSUserDefaults.
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
[defs setInteger:0 forKey:@"score"];
[defs setInteger:3 forKey:@"lives"];
[defs release];
Im not sure what the issue is
On some crashes there isnt even a crash report in the console.
Thanks