• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: I'm having trouble retaining a NSColor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: I'm having trouble retaining a NSColor
      • From: "Alan Smith" <email@hidden>
References: 
 >I'm having trouble retaining a NSColor (From: "Alan Smith" <email@hidden>)

  • Prev by Date: Re: Contextual Menu doesn't respond to control+click
  • Next by Date: Re: Objects In Nibs Losing Settings
  • Previous by thread: Re: I'm having trouble retaining a NSColor
  • Next by thread: Re: I'm having trouble retaining a NSColor
  • Index(es):
    • Date
    • Thread