On 30 Aug 2008, at 11:54 am, Brad Gibbs wrote:

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

Hmm, yes. Well, what is your code doing? It's first taking the intValue from elementBarGradientAngleTextField. It then sets that value in the user defaults, quite correctly, using the key "ICNElementBarGradientAngleKey" which I take it is defined somewhere as a constant literal string. You then ask the KEY for its intValue. The key's intValue is indeed 0, because the key is "ICNElementBarGradientAngleKey" which isn't a number.

I think you mean:

NSLog(@"Element bar angle is now: %d", [defaults integerForKey:ICNElementBarGradientAngleKey]);

which should return the same as the first log.


meant to be used with an int, or an object, such as NSUInteger? What am I doing wrong?


NSInteger is NOT an object. It's just another name for int. Just because something is prefixed by 'NS' do not assume its an object - there are many, many things in Cocoa that are prefixed 'NS' that are not objects - types, constants, functions, you name it. You can really tell what is or isn't an object purely from its name alone - check the documentation.

hth,

Graham

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to