This repository has been archived by the owner on Dec 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
Swift compatibility #1
Comments
Good question. It looks like a very thin wrapper may be required for Swift compatibility with the C portion of the library: http://stackoverflow.com/questions/24088312/does-swift-not-work-with-function-pointers I'll investigate in more detail when I get a chance. If you get things working in the meantime please feel free to share or submit a pull request. |
For now I'm using next workaround. Make typedef enum INTUEasingFunction {
INTULinear_,
INTUEaseInSine_,
INTUEaseOutSine_,
INTUEaseInOutSine_,
INTUEaseInQuadratic_,
INTUEaseOutQuadratic_,
INTUEaseInOutQuadratic_,
INTUEaseInCubic_,
INTUEaseOutCubic_,
INTUEaseInOutCubic_,
INTUEaseInQuartic_,
INTUEaseOutQuartic_,
INTUEaseInOutQuartic_,
INTUEaseInQuintic_,
INTUEaseOutQuintic_,
INTUEaseInOutQuintic_,
INTUEaseInExponential_,
INTUEaseOutExponential_,
INTUEaseInOutExponential_,
INTUEaseInCircular_,
INTUEaseOutCircular_,
INTUEaseInOutCircular_,
INTUEaseInBack_,
INTUEaseOutBack_,
INTUEaseInOutBack_,
INTUEaseInElastic_,
INTUEaseOutElastic_,
INTUEaseInOutElastic_,
INTUEaseInBounce_,
INTUEaseOutBounce_,
INTUEaseInOutBounce_
}
INTUEasingFunction; Change - (CGFloat)progress
{
switch(self.easingFunction) {
case INTULinear_: return INTULinear([self percentComplete]);
case INTUEaseInSine_: return INTUEaseInSine([self percentComplete]);
case INTUEaseOutSine_: return INTUEaseOutSine([self percentComplete]);
case INTUEaseInOutSine_: return INTUEaseInOutSine([self percentComplete]);
case INTUEaseInQuadratic_: return INTUEaseInQuadratic([self percentComplete]);
case INTUEaseOutQuadratic_: return INTUEaseOutQuadratic([self percentComplete]);
case INTUEaseInOutQuadratic_: return INTUEaseInOutQuadratic([self percentComplete]);
case INTUEaseInCubic_: return INTUEaseInCubic([self percentComplete]);
case INTUEaseOutCubic_: return INTUEaseOutCubic([self percentComplete]);
case INTUEaseInOutCubic_: return INTUEaseInOutCubic([self percentComplete]);
case INTUEaseInQuartic_: return INTUEaseInQuartic([self percentComplete]);
case INTUEaseOutQuartic_: return INTUEaseOutQuartic([self percentComplete]);
case INTUEaseInOutQuartic_: return INTUEaseInOutQuartic([self percentComplete]);
case INTUEaseInQuintic_: return INTUEaseInQuintic([self percentComplete]);
case INTUEaseOutQuintic_: return INTUEaseOutQuintic([self percentComplete]);
case INTUEaseInOutQuintic_: return INTUEaseInOutQuintic([self percentComplete]);
case INTUEaseInExponential_: return INTUEaseInExponential([self percentComplete]);
case INTUEaseOutExponential_: return INTUEaseOutExponential([self percentComplete]);
case INTUEaseInOutExponential_: return INTUEaseInOutExponential([self percentComplete]);
case INTUEaseInCircular_: return INTUEaseInCircular([self percentComplete]);
case INTUEaseOutCircular_: return INTUEaseOutCircular([self percentComplete]);
case INTUEaseInOutCircular_: return INTUEaseInOutCircular([self percentComplete]);
case INTUEaseInBack_: return INTUEaseInBack([self percentComplete]);
case INTUEaseOutBack_: return INTUEaseOutBack([self percentComplete]);
case INTUEaseInOutBack_: return INTUEaseInOutBack([self percentComplete]);
case INTUEaseInElastic_: return INTUEaseInElastic([self percentComplete]);
case INTUEaseOutElastic_: return INTUEaseOutElastic([self percentComplete]);
case INTUEaseInOutElastic_: return INTUEaseInOutElastic([self percentComplete]);
case INTUEaseInBounce_: return INTUEaseInBounce([self percentComplete]);
case INTUEaseOutBounce_: return INTUEaseOutBounce([self percentComplete]);
case INTUEaseInOutBounce_: return INTUEaseInOutBounce([self percentComplete]);
}
} And pass enum values as |
That's an acceptable workaround, but not ideal for long term. It should be pretty straightforward to add a thin Swift wrapper around the C code. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Trying to call
INTUAnimationEngine.animateWithDuration(1.0, delay: 0.0, easing: INTUEaseInBounce, animations: nil, completion: nil)
from swift code but getting "Extra argument 'easing' in call" error. Probably there is something with this line fromINTUEasingFunctions.h
:typedef CGFloat (*INTUEasingFunction)(CGFloat);
How should I use this method from swift code?
The text was updated successfully, but these errors were encountered: