Re: CALayer, CATextLayer, and inheritance . . .
Re: CALayer, CATextLayer, and inheritance . . .
- Subject: Re: CALayer, CATextLayer, and inheritance . . .
- From: Gordon Apple <email@hidden>
- Date: Sun, 11 Jan 2009 12:24:19 -0600
- Thread-topic: CALayer, CATextLayer, and inheritance . . .
Well, it's good to know that. One thing I had assumed (possibly
erroneously) is that other initializers and factory methods would internally
call init for basic initialization. That would be consistent with your
claim that factory methods are just convenience methods. I found out that's
not the case for QCCompositionLayer (compositionLayerWithComposition) when I
did an override of init in an attempt to initialize my subclass iVars and it
wasn't getting called. Of course, alloc-init wouldn't work here anyway
because there's no setter for composition -- you'd have to use
initWithComposition. I assume that's what the factory method does.
(QCCompositionLayer also does not run under GC, which we recently verified.
Bug ID# 6477593.)
On 1/11/09 12:47 AM, "Scott Anguish" <email@hidden> wrote:
>
> On 10-Jan-09, at 7:26 PM, Michael A. Crawford wrote:
>
>> I know that the documentation states the CALayer entities are to be
>> allocated with class methods:
>>
>> CALayer* l = [CALayer layer];
>> CATextLayer* tl = [CATextLayer layer];
>>
>> Am I creating a problem by not allocating and initializing my layers
>> using the class methods?
>
> No. it is perfectly valid to do that. init is the designated
> initializer for CALayer. +layer is simply a convenience. The header
> shows this, although the doc didn't (until just now -- so next push it
> will show the below)
>
> what you are not supposed to do is use initWithLayer:, that's a
> special method only used when you create custom presentation layers
> for a model layer (i.e. very, very rarely) (see the doc for more
> information).
>
> init
> Returns an initialized CALayer object.
>
> - (id)init
>
> Return Value
> An initialized CALayer object.
>
> Discussion
> This is the designated initializer for CALayer.
>
> See Also
> + layer
> Declared InCALayer.h
G. Apple
_______________________________________________
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