从 'BaseViewController' 到 'FUIAuthDelegate' 的条件转换总是成功
Conditional cast from 'BaseViewController' to 'FUIAuthDelegate' always succeeds
请注意,我是 Xcode10.1.
的新手
我在 Xcode 中对我的移动应用实施了 Firebase 身份验证;登录有效,但我收到一条错误消息
Conditional cast from 'BaseViewController' to 'FUIAuthDelegate' always
succeeds
我看到的症状是登录屏幕只会在我完全关闭 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)
}
}
}
首先,错误是警告(黄色)。
如果一个class/struct采用一个协议,它成为编译器方面的协议,所以BaseViewController
是 FUIAuthDelegate
.
条件转换是多余的,这就是警告告诉您的内容。
let authUI = FUIAuth.defaultAuthUI()!
authUI.delegate = self
请注意,我是 Xcode10.1.
的新手我在 Xcode 中对我的移动应用实施了 Firebase 身份验证;登录有效,但我收到一条错误消息
Conditional cast from 'BaseViewController' to 'FUIAuthDelegate' always succeeds
我看到的症状是登录屏幕只会在我完全关闭 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)
}
}
}
首先,错误是警告(黄色)。
如果一个class/struct采用一个协议,它成为编译器方面的协议,所以BaseViewController
是 FUIAuthDelegate
.
条件转换是多余的,这就是警告告诉您的内容。
let authUI = FUIAuth.defaultAuthUI()!
authUI.delegate = self