On Nov 3, 2008, at 10:53 AM, Gordon Apple wrote:

   The following example is one of several I have run into recently.

Inheritance is as follows: CAKeyframeAnimation: CAPropertyAnimation : CAAnimation. CAKeyframeAnimation has no explicit initializer or factory method. Dudney's book uses [CAKeyframeAnimation animation] to create an
object.  However, CAKeyframeAnimation has no such factory method.
CAAnimation does. Why should I assume that the "animation" factory method will return an object of class CAKeyframeAnimation instead of CAAnimation
when it is not re-defined in CAKeyframeAnimation.h?

   The docs say that CAKeyframeAnimation shoud be created with the
inherited (from CAPropertyAnimation) animationWithKeyPath factory method.
That raises the same issue.

Is there a basic assumption that such factory methods are implicitly
redefined for all subclasses?

In Objective-C, classes are objects with inheritance. What you'll get back from a class convenience method is going to depend on how its implemented (and not necessarily whether it is redefined by a subclass.)

Consider

@interface Person : NSObject
+ (id)person
@end

@interface Child : Base
@end

Case #1

@implementation Person
+ (id)person
{
        return [[[self alloc] init] autorelease];
}
@end

Case #2

@implementation Person
+ (id)person
{
        return [[[Person alloc] init] autorelease];
}
@end

In case #1, [Child person] will return a Child instance to us.
In case #2, [Child person] will return a Person instance to us.

I think the CoreAnimation authors intended for case #1, but that's not what the documentation says.

        Creates and returns a new CAAnimation instance.
        + (id)animation

        Return Value
        An CAAnimation object whose input values are initialized.

I'd recommend filing a bug against the documentation for clarification/ correction.

Jim
_______________________________________________

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