objectForKey
will return nil if no key found Reference
intValue is a method not attribute. Link
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *string = [ud objectForKey:@"scoreStringKey"];
if (string != nil)
{
highScore = [string intValue]; <--- right way to convert into integer
}
else
{
highScore = 0;
}