• 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
CAAnimation working with float, but not with int?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CAAnimation working with float, but not with int?


  • Subject: CAAnimation working with float, but not with int?
  • From: Kevin Barnes <email@hidden>
  • Date: Tue, 15 Jan 2008 12:24:51 -0600
  • Importance: Normal

I'm creating a view and animating an instance variable of that view. If the instance variable is a float, everything works perfectly, but if I change the float to an int, the animation doesn't happen. It appears that the "animationWithKeyPath" function doesn't even get called if my ivar is an int.
Can anyone tell me why my code doesn't work?


    Class cls = objc_allocateClassPair([NSView class], "AnimatedView", 0);
    class_addIvar(cls, "animValue", sizeof(int), log2(sizeof(int)), "i");
    Method setterImpl = class_getClassMethod([MyView class], @selector(setAnimValue:));
    class_addMethod(cls, @selector(setAnimValue:), method_getImplementation(setterImpl), "v@:i");
    objc_registerClassPair(cls);

    NSView *av = class_createInstance(cls, 0);
    [av init];
    CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"animValue"];
    [anim setFromValue:[NSNumber numberWithInt:0]];
    NSDictionary *dic = [NSDictionary dictionaryWithObject:anim forKey:@"animValue"];
    [av setAnimations:dic];
    [self addSubview:av];

    objc_msgSend([av animator], @selector(setAnimValue:), (int)100);


Implementation of setAnimValue:

+(void)setAnimValue:(int) val {
    printf("setAnimValue val=%d\n", val);
}


_________________________________________________________________

_______________________________________________

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

  • Prev by Date: Re: NSWindow and autorelease with dynamic binary
  • Next by Date: Re: NSWindow and autorelease with dynamic binary
  • Previous by thread: Re: NSPopupButton on Toolbar with Image instead?
  • Next by thread: Fwd: CAAnimation working with float, but not with int?
  • Index(es):
    • Date
    • Thread