iosswiftswift3appdelegatelocalytics

Getting crash "Could not cast value of type 'LLAppDelegateProxy' "


I have a method in my AppDelegate file. Which I was calling from another class. But after implementing Localytics I am getting a crash. Here is how I was calling the method.

 let delegate = UIApplicatin.shared.delegate as ! AppDelegate
 delegate.myFunction()

I have tried this answer from Stack Overflow. Its does not crash the app but method is not called.


Solution

  • Got it working. Actually I was missing the line in didFinishLauncihingWithOptions as mentioned in This answer. We have to do this.

        func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
            AppDelegate.originalAppDelegate = self
        }