On 11-Jan-09, at 1:24 PM, Gordon Apple wrote:

   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.

You can't assume that. That's where the designated initializer comes in.

 That would be consistent with your
claim that factory methods are just convenience methods.

that's not a hard fast rule necessarily. but is true in the CALayer case, and (as it turns out in QCComposerLayer - as the header say)



On 1/11/09 12:47 AM, "Scott Anguish" <sc...@cocoadoc.com> 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 (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 arch...@mail-archive.com

Reply via email to