On Sun, Oct 26, 2008 at 4:20 PM, Antonio Nunes <[EMAIL PROTECTED]>wrote:

> On 26 Oct 2008, at 14:25, DKJ wrote:
>
>  1. Is there such a thing as a CGColor class? I don't see it in the
>> documentation; but "CGColor" is what Instruments lists as the leaked
>> objects.
>>
>
> You are creating CGColor objects to which you receive pointers of type
> CGColorRef. You are at C level here, not Objective-C.
>
>  2. Are the CGColor objects being leaked when I remove MyCALayer objects
>> from myArray? Should I set foregroundColor to nil when doing this?
>>
>
> You need to make sure in the MyCALayer dealloc method to release the color
> you created during init using something like
> CGColorRelease(self.foregroundColor).
>

Bad idea: you don't know for sure self.foregroundColor instance will be the
one created in the first place (the one that is leaking). The flaw is at the
beginning:

        self.foregroundColor =
               CGColorCreateGenericRGB( 1.0, 1.0, 0.9, 1.0 );

should be

       CGColorRef color = CGColorCreateGenericRGB( 1.0, 1.0, 0.9, 1.0 );
       self.foregroundColor = color;
       CFRelease(color);

-- 
Julien
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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