views:

82

answers:

1

I don't understand what is problem here! after I compile it, always show me: "assignment makes pointer from integer without a cast" I don't know what is the problem! Please let me, thanks.

SAVE

 NSUserDefaults *percentChecker = [NSUserDefaults standardUserDefaults]; 
 [percentChecker setInteger:0 forKey:percentCheckerSaveKey];

LOAD

NSUserDefaults *percentChecker = [NSUserDefaults standardUserDefaults]; 
NSString *percentString;

//Alert! 
percentString = [percentChecker integerForKey:percentCheckerSaveKey];
+2  A: 

It's exactly what it's telling you. percentString is a pointer, but integerForKey: returns an integer. Assigning that integer to a pointer is making a "pointer from an integer without a cast". Why are you saving an integer and trying to load it later as a string?

Carl Norum
thanks.You were right. I change it to: NSInteger percentString; percentString = [percentChecker integerForKey:percentCheckerSaveKey];