Skip navigation.
 
mlRe: I'm having trouble retaining a NSColor
FROM : Shawn Erickson
DATE : Mon Aug 28 20:42:41 2006

On 8/28/06, Alan Smith <<email_removed>> 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];
}

Related mailsAuthorDate
mlI'm having trouble retaining a NSColor Alan Smith Aug 28, 20:02
mlRe: I'm having trouble retaining a NSColor I. Savant Aug 28, 20:11
mlRe: I'm having trouble retaining a NSColor I. Savant Aug 28, 20:14
mlRe: I'm having trouble retaining a NSColor Matt Neuburg Aug 28, 20:27
mlRe: I'm having trouble retaining a NSColor Shawn Erickson Aug 28, 20:42
mlRe: I'm having trouble retaining a NSColor Alan Smith Aug 29, 00:36
mlRe: I'm having trouble retaining a NSColor Rosyna Aug 29, 00:52
mlRe: I'm having trouble retaining a NSColor Alan Smith Aug 29, 01:48
mlRe: I'm having trouble retaining a NSColor Steve Bird Aug 29, 01:57
mlRe: I'm having trouble retaining a NSColor Ricky Sharp Aug 29, 02:25
mlRe: I'm having trouble retaining a NSColor Alan Smith Aug 29, 03:06
mlRe: I'm having trouble retaining a NSColor Shawn Erickson Aug 29, 03:13
mlRe: I'm having trouble retaining a NSColor Andy Lee Aug 29, 15:33
mlRe: I'm having trouble retaining a NSColor Matt Neuburg Aug 29, 19:09
ml[SOLVED] I'm having trouble retaining a NSColor Alan Smith Sep 5, 05:20