Re: Problem with NSColor since 10.2
Re: Problem with NSColor since 10.2
- Subject: Re: Problem with NSColor since 10.2
- From: Frank Blome <email@hidden>
- Date: Wed, 28 Aug 2002 16:37:39 +0200
Hi Ondra!
Am Mittwoch, 28.08.02 um 15:28 Uhr schrieb Ondra Cada:
On Wednesday, August 28, 2002, at 09:28 , Frank Blome wrote:
Another question on the new DevTools from Jaguar (they really drive
me crazy). These part of the source code has worked fine before I had
upgraded:
I defined in my .h:
...
NSData *allowColor;
...
-------------------
// While loading the Preferences I do:
...
allowColor = [defaults objectForKey: @"AllowColor"];
if (allowColor == nil)
allowColor = [NSArchiver archivedDataWithRootObject:[NSColor
blueColor]];
Suspicious: since allowColor is not an automatic variable, it seems
you should retain. (Also it would seem to be better to keep the
NSColor locally, not the archived NSData, but of course you might have
strong reasons for that.)
It will released in "applicationWillTerminate" - this is the only thing
that I do before quitting the Application. The reason to store it in a
NSData is because the color will/can change often, so it is easier to
save them (there are 4 diffreent colors) in the preferences, I believe.
[colorWellAllow setColor:[NSUnarchiver
unarchiveObjectWithData:allowColor]];
...
-------------------
// When I'm saving the color, I do:
- (IBAction)setAllowColor:(id)sender
{
NSColor *color = [sender color];
allowColor = [NSArchiver archivedDataWithRootObject:color];
ditto
Ditto ;-)
[[NSUserDefaults standardUserDefaults] setObject:allowColor
forKey: @
"AllowColor"];
[self loadPreferences];
}
...
Anyone knows whats goin' on here? Have I done a general mistake, or
is the code OK?
Short of memory management,
What did you mean with it?
it looks right. What's the matter?
It crashed with signal 11 (SIGSEGV). But when I use the predefined
Colors (i.e. [NSColor blueColor]) everything works fine...
Frank
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.