从“ BaseViewController”到“ FUIAuthDelegate”的条件转换始终成功

时间:2019-01-05 08:14:30

标签: ios firebase xcode10.1

请注意,我是Xcode10.1的完全新手。

我已经在Xcode中为我的移动应用实现了Firebase身份验证;登录有效,但是我收到一条错误消息

  

始终从“ BaseViewController”强制转换为“ FUIAuthDelegate”   成功

,我看到的症状是,仅当我完全关闭Xcode并重新启动应用程序时,才会出现登录屏幕。

在网络上找不到对此错误的任何引用

class BaseViewController: UIViewController, SlideMenuDelegate, FUIAuthDelegate {
    override func viewDidLoad() {
        super.viewDidLoad()
        addSlideMenuButton()
        // Do any additional setup after loading the view.
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        if Auth.auth().currentUser != nil {
        } 
        else {
            let authUI = FUIAuth.defaultAuthUI()
            authUI?.delegate = self as? FUIAuthDelegate ***this is where im receiving the error***

            let providers: [FUIAuthProvider] = [
                FUIGoogleAuth()]

            authUI?.providers = providers
            let authViewController = authUI!.authViewController()
            self.present(authViewController, animated: true, completion: nil)
        }
    }
}

1 个答案:

答案 0 :(得分:1)

首先,错误 警告 (黄色)。

如果类/结构采用协议,那么就编译器而言,它成为协议,因此BaseViewController FUIAuthDelegate

条件转换是多余的,这就是警告告诉您的内容。

let authUI = FUIAuth.defaultAuthUI()!
authUI.delegate = self