• 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
I'm having trouble retaining a NSColor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: I'm having trouble retaining a NSColor
      • From: Andy Lee <email@hidden>
    • Re: I'm having trouble retaining a NSColor
      • From: "Shawn Erickson" <email@hidden>
    • Re: I'm having trouble retaining a NSColor
      • From: "I. Savant" <email@hidden>
    • Re: I'm having trouble retaining a NSColor
      • From: "I. Savant" <email@hidden>
  • Prev by Date: Exporting a movie
  • Next by Date: Re: I'm having trouble retaining a NSColor
  • Previous by thread: Exporting a movie
  • Next by thread: Re: I'm having trouble retaining a NSColor
  • Index(es):
    • Date
    • Thread