Could not cast value of type 'LLAppDelegateProxy'

喜欢而已 提交于 2020-01-13 10:20:58

问题


I have integrated the Localtyics iOS SDK. After this I am getting the error like below: Could not cast value of type 'LLAppDelegateProxy'

It means I am unable to get a reference of the App delegate object. I am in trouble now because I want Localytics & want a reference object of App delegate as well.

Does any body know a solution of this?


回答1:


Localytics replaces your AppDelegate behind-the-scenes with their proxy class (LLAppDelegateProxy). Localytics suggests creating a static reference to your original AppDelegate for access like so:

class AppDelegate: UIResponder, UIApplicationDelegate {
    static var originalAppDelegate: AppDelegate!

    // ...

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

        // ...

}

Access using:

AppDelegate.originalAppDelegate.someMethod()


来源:https://stackoverflow.com/questions/37915873/could-not-cast-value-of-type-llappdelegateproxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!