• 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: Leaking CGColor objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Leaking CGColor objects


  • Subject: Re: Leaking CGColor objects
  • From: David Duncan <email@hidden>
  • Date: Mon, 27 Oct 2008 10:40:04 -0700

On Oct 26, 2008, at 1:06 PM, DKJ wrote:

In the documentation, the foregroundColor property is defined like this:

	@property CGColorRef foregroundColor

There's no retain parameter.


Correct, however the property is implemented as if it was retain. This is because the compiler will generate a warning (or error, can't recall which at the moment) when you declare a retained property for a non-Obj-C object - which as far as the compiler can tell is all Core Foundation data types.

For the purposes of Core Animation at least, you can assume that all properties that operate on Core Foundation data types are retained properties and that the appropriate Core Animation object will property release them when that object is deallocated. Thus the correct way to assign a foregroundColor is

CGColorRef color = CGColorCreateGenericRGB(...);
self.foregroundColor = color;
CFRelease(color);

And you don't need to release it yourself in a custom dealloc method (the layer is responsible for that).
--
David Duncan
Apple DTS Animation and Printing


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Leaking CGColor objects (From: Charles Steinman <email@hidden>)
 >Re: Leaking CGColor objects (From: DKJ <email@hidden>)

  • Prev by Date: Re: NSImage/NSImageView opacity (solved)
  • Next by Date: Re: Cocoa and Printing (Advanced Q)
  • Previous by thread: Re: Leaking CGColor objects
  • Next by thread: Re: Leaking CGColor objects
  • Index(es):
    • Date
    • Thread