Re: I'm having trouble retaining a NSColor
Re: I'm having trouble retaining a NSColor
- Subject: Re: I'm having trouble retaining a NSColor
- From: "Shawn Erickson" <email@hidden>
- Date: Mon, 28 Aug 2006 11:42:41 -0700
On 8/28/06, Alan Smith <email@hidden> wrote:
Here is the code where the color is retained:
- (void)setHighlightColor:(NSColor*)color
Try something like the following (I personally use the first of the
three and I believe Apple recommends it as well)...
- (void)setHighlightColor:(NSColor*)color
{
if (color != highlightColor) {
[highlightColor release];
highlightColor = [color retain]; //or copy if what you get
could possibly be mutable
}
}
...or...
- (void)setHighlightColor:(NSColor*)color
{
[highlightColor autorelease];
highlightColor = [color retain]; //or copy if what you get could
possibly be mutable
}
...or...
- (void)setHighlightColor:(NSColor*)color
{
NSColor* original = highlightColor;
highlightColor = [color retain]; //or copy if what you get could
possibly be mutable
[original release];
}
_______________________________________________
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