" UIApplication.sharedApplication()代表" swift_dynamicCastClassUnconditional

时间:2014-12-19 05:34:09

标签: swift appdelegate

尝试访问我的AppDelegate实例,但使用swift_dynamicCastClassUnconditional失败。

class AppDelegate: UIResponder, UIApplicationDelegate {
    class func getInstance() -> AppDelegate {
        let delegate = UIApplication.sharedApplication().delegate;
        return delegate as AppDelegate;
    }
    ........
}

有什么想法吗?感谢。

1 个答案:

答案 0 :(得分:1)

原来它是由Urbanairship图书馆引起的。当应用程序初始化时,我调用了api

    var uaconfig = UAConfig.defaultConfig() as UAConfig
    UAirship.setLogLevel(UALogLevel.Debug)
    UAirship.takeOff(uaconfig)
    UAPush.shared().userNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
    UAPush.shared().userPushNotificationsEnabled = true

我删除上面的代码后,现在一切都很好。