Search code examples
swiftlottie

Call a function from a separate class not working


I am calling a function in a different class that simply removes a lottie animation. I do this by calling...

RedeemController().removeAnimationFromSuperview()

Which enters the function (as proven by a print statement). However the animation does not disappear from the view.

When I call the same function from within the class that the animation is defined, the animation is removed from the view as expected. Here is the function. Very simple.


    fileprivate func removeAnimationFromSuperview(){
        animationViewDraw.removeFromSuperview()
        print("Entered")

    }

I would expect this animation to disappear. Thanks for your help!!!!


Solution

  • You are creating new instance of RedeemController that has it's own properties, instead you have to use the instance that you currently have myControllerInstance.removeAnimationFromSuperview()