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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to