Also, [ICNElementBarGradientAngleKey intValue] will try to turn the
key into a number, not get it's value. You want to use:
[[defaults objectForKey: ICNElementBarGradientAngleKey] intValue];
Andrei
On 30.08.2008, at 04:54, Brad Gibbs wrote:
I'm having a hard time with what should be a simple task - storing
an integer for a gradient angle as a user default and then updating
the screen. When I quit the app and open it again, the NSTextField
shows the last value I set for the gradient, but with the following
code:
- (IBAction)changeElementBarGradientAngle:(id)sender {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSLog(@"gradient angle is %d", [elementBarGradientAngleTextField
intValue]);
[defaults setInteger:[elementBarGradientAngleTextField intValue]
forKey:ICNElementBarGradientAngleKey];
NSLog(@"Element bar angle is now: %d",
[ICNElementBarGradientAngleKey intValue]);
}
I get:
2008-08-29 18:42:10.627 Icon[35645:10b] gradient angle is 75
2008-08-29 18:42:10.628 Icon[35645:10b] Element bar angle is now: 0
I've also tried turning the int into an NSNumber object and using
defaults setObject: foKey: without success.