I'm having trouble retaining a NSColor
I'm having trouble retaining a NSColor
- Subject: I'm having trouble retaining a NSColor
- From: "Alan Smith" <email@hidden>
- Date: Mon, 28 Aug 2006 14:02:53 -0400
Here is the code where the color is retained:
- (void)setHighlightColor:(NSColor*)color
{
[highlightColor release];
if (color != nil)
{
NSLog(@"before HEBrowserCell retains color, its retain count
equals: %i", [color retainCount]);
highlightColor = [color retain];
NSLog(@"after HEBrowserCell retains color, its retain count
equals: %i", [color retainCount]);
}
NSLog(@"highlightColor = %@", highlightColor);
}
- (NSColor *)highlightColorInView:(NSView *)controlView
{
NSLog(@"highlightColor = %", [highlightColor retainCount]);
return highlightColor;
}
Here is the code where the color is passed in:
[cell setHighlightColor: [NSColor colorWithCalibratedRed: 0.2941
green: 0.5824 blue: 0.8706 alpha: 1.0]];
And this is the output:
before HEBrowserCell retains color, its retain count equals: 1
after HEBrowserCell retains color, its retain count equals: 2
highlightColor = NSCalibratedRGBColorSpace 0.2941 0.5824 0.8706 1
That's all well and good but, when the code gets to the third log
message it crashes. All I wanted was to verifiy that the color existed
and it crashes.
Obviously I'm missing something.
All help is appreciated, Alan
P.S. I tried: highlightColor = [color copy]; but it makes no difference.
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden