Re: CALayer, CATextLayer, and inheritance . . .
Re: CALayer, CATextLayer, and inheritance . . .
- Subject: Re: CALayer, CATextLayer, and inheritance . . .
- From: Gordon Apple <email@hidden>
- Date: Sat, 10 Jan 2009 21:55:31 -0600
- Thread-topic: CALayer, CATextLayer, and inheritance . . .
I would definitely recommend using the factory methods. You have no
idea of what is going on inside those methods, but you better believe you
need it, whatever it is. Also, I've found that some of those methods don't
even cal init, which I found out when my own iVars were not getting
initialized when I overrode init. You can use the factory methods for your
own subclass. We had that discussion here recently. Apparently, almost all
of the factory methods use "self" in the class method when creating the
object, so it will still work for your own subclass.
On 1/10/09 9:08 PM, "email@hidden"
<email@hidden> wrote:
> Ok, I think I'm hosed but I need one of you bright people to tell me
> just how bad it is.
>
> I'm working on a avionics simulation project that leverages Core
> Animation and layers in order to composite various elements of the
> display. These elements all have various behaviors and attributes
> based on the information they are meant to convey to the person
> reading them. For example, a compass displays directional information
> using values ranging from 0 to 359. I decided to abstract away the
> standard rotational transformation interface on a CALayer by creating
> a sub-class that knows about the compass interface. This subclass
> automatically converts degrees to radians, performs coordinate
> transformations in order to get rotation to happen in the proper
> direction, and sets up the associated animation, as well as handing
> delegate callbacks.
>
> At first it all seemed to work well, but when I created my first
> derived CATextLayer class, I began to have strange issues. I won't
> bore you with the details on that but here is the question: I'm
> allocating and initializing my sub-classed layers using the alloc and
> init methods:
>
> @interface CompassLayer : CALayer . . .
> @interface SpeedInfoLayer : CATextLayer . . .
>
> CompassLayer* c = [[CompassLayer alloc] init];
> SpeedInfoLayer* si = [[SpeedInfoLayer alloc] init];
>
> 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?
_______________________________________________
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