1

I am extremely new to coding. All I did was update my Xcode software and received this error. Thank you for all of your help! This first line is where my error occured:

HighScore = [[NSUserDefaults standardUserDefaults] integerForKey:@"HighScoreSaved"];

Intro3.text = [NSString stringWithFormat:@"High Score: %i", HighScore];

I declared it here but I don't know if this is relevant

int HighScore; 
  • 2
    This is not related to Xcode. This is at best related to the change in the default "strictness" of the compiler (likely) or to some change in the Foundation library (typedef of `NSInteger` or size of `int`, but that's less likely). The problem is that the `integerForKey:` method returns a `long` (alias `NSInteger`), which the `int` is incapable of holding in its entirety -- so it will be truncated. If you know your high score values will always fit into an `int`, you can safely ignore this warning. – The Paramagnetic Croissant May 22 '14 at 19:49
  • 3
    Your first mistake is using LeadingUpperCase for a variable name. – Hot Licks May 22 '14 at 19:53
  • user3477950 is right. One more thing: You should follow the convention (among others) that in Obj-C variables start with a lower case letter (in contrast to classes). This makes code more readable. – Reinhard Männer May 22 '14 at 19:54
  • This is in so far Xcode related as starting with Xcode 5.1.1?, iOS apps are by default compiled for 32-bit **and** for 64-bit. - Similar question here: http://stackoverflow.com/questions/16918826/objective-c-implicit-conversion-loses-integer-precision-nsuinteger-aka-unsig – Martin R May 22 '14 at 20:18
  • You can typecast your HighScore using (int)HighScore or change the %i to %ld. Or, you could try going to Xcode's Build Phases I believe and type "Integer" into the search field. Try changing the "Implicit conversion of integer value..." to the opposite value, so if it was a "NO", change to "YES" or vice versa. – Zhang May 25 '14 at 14:35

0 Answers0