Re: Leaking CGColor objects
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