Re: Newb Question re NSUserDefaults and Ints

2008-08-30 Thread Michael Ash
On Sat, Aug 30, 2008 at 4:35 PM, Brad Gibbs <[EMAIL PROTECTED]> wrote: > While I did learn some things from this, I'm confused about NSUserDefaults > and the values it can store. I created an NSMutableDictionary to register > the defaults, which is, I believe archived as a property list. Floats c

Re: Newb Question re NSUserDefaults and Ints

2008-08-30 Thread Brad Gibbs
Thanks for all of the responses. After some monkeying around, I figured out that I'd used an NSNumber where I should have used an NSString. The code is now compiling and running happily. While I did learn some things from this, I'm confused about NSUserDefaults and the values it can store

Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Graham Cox
On 30 Aug 2008, at 2:04 pm, Graham Cox wrote: You can really tell I meant of course that you CAN'T really tell... G. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Cont

Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Graham Cox
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", [ICNElementBarGradie

Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Ken Thomases
On Aug 29, 2008, at 8:54 PM, 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 gradie

Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Graham Cox
On 30 Aug 2008, at 12:14 pm, Andrei Kolev wrote: Brad, You can't store an int into [...] user defaults. Sure you can: - (void)setInteger:(NSInteger)value forKey:(NSString *)defaultName; Note that NSInteger == int, so the book doesn't have a typo, it's just using the pre-Leopard type co

Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Brad Gibbs
Well, it appears that I need to convert either an NSNumber or an NSString to a CGFloat, rather than an int: - (void)drawInRect:(NSRect)rect angle:(CGFloat)angle There don't appear to be any methods in either NSNumber or NSString to do this On Aug 29, 2008, at 7:36 PM, Brad Gibbs wrote

Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Andrei Kolev
Brad, You can't store an int into a Dictionary or user defaults. For the objects you can use, see here: http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/AboutPropertyLists.html#/ /apple_ref/doc/uid/20001010 NSNumber and NSString should work. Also, [ICNEleme

Re: Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Brad Gibbs
Thanks. I'd read that dictionaries and plists were particular in the types they accept, but I was looking at page 201 of Hillegass (3rd edition), which shows: - (void)setInteger:(int)value forKey:(NSString *)defaultName and - (int)integerForKey:(NSString *)defaultName and blindly followe

Newb Question re NSUserDefaults and Ints

2008-08-29 Thread Brad Gibbs
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)ch