• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CALayer, CATextLayer, and inheritance . . .
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CALayer, CATextLayer, and inheritance . . .


  • Subject: Re: CALayer, CATextLayer, and inheritance . . .
  • From: "Michael A. Crawford" <email@hidden>
  • Date: Sun, 11 Jan 2009 13:12:45 -0800

Thanks for that, Scott. Due to your input, I found the problem. It turns out [super init] was not being called for CATextLayer. Here is my hierarchy:

NSObject<-CALayer<-CATextLayer<-NDInfoLayer<-SpeedInfoLayer

NDInfoLayer contains common attributes and behavior (NSFont(s), NSMutableAttributedString(s)), and other items that are used by multiple info layers types along with common methods that operate on them. SpeedInfoLayer is a specialization of NDInfoLayer that knows how to interpret and display speed information, which is generated from the model. NDInfoLayers using a custom initializer instead of init. I had to add a line to the custom initializer in NDInfoLayer in order to initialize the underlying CATextLayer. Now, all is well.

-Michael
----------------------
The difference between genius and stupidity...
...is that genius has its limits."

-- Albert Einstein



On Jan 10, 2009, at 10:47 PM, Scott Anguish 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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >CALayer, CATextLayer, and inheritance . . . (From: "Michael A. Crawford" <email@hidden>)
 >Re: CALayer, CATextLayer, and inheritance . . . (From: Scott Anguish <email@hidden>)

  • Prev by Date: Button Bindings
  • Next by Date: Mac Pro memory sizes
  • Previous by thread: Re: CALayer, CATextLayer, and inheritance . . .
  • Next by thread: Re: CALayer, CATextLayer, and inheritance . . .
  • Index(es):
    • Date
    • Thread