简体   繁体   English

iOS的Google firebase Auth文档中是否有错误? 当我尝试代码时,这些是错误

[英]Is there a error in the Google firebase Auth documentation for iOS? As I tried the code and these are the errors

在此处输入图片说明

I am developing a ios app and tried connecting it to firebase and use its user auth function I am encountering several errors and I would also request you ppl to review my code. 我正在开发一个ios应用程序,尝试将其连接到firebase并使用其用户身份验证功能,但遇到一些错误,我也将要求您ppl查看我的代码。 I trying very hard but nothing is solving these errors. 我非常努力,但是没有什么可以解决这些错误。 Pls help 请帮助

I tried searching any updates in code and any answers to the error but unfortunately, I got nothing. 我尝试搜索代码中的所有更新以及该错误的任何答案,但不幸的是,我什么也没得到。 I am using Xcode 11 beta and coding for iOS 12.2 我正在使用Xcode 11 beta并为iOS 12.2编码

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    // [START auth_listener]
    var handle = Auth.auth().addStateDidChangeListener { (auth, user) in
      // [START_EXCLUDE]
      self.setTitleDisplay(user) //Error "Value of type 'ViewController' has no member 'setTitleDisplay'"
      self.tableView.reloadData() //Error "Value of type 'ViewController' has no member 'tableView'"



guard let strongSelf = self else { return } //Error "Initializer for conditional binding must have Optional type, not 'ViewController" 
        // [START_EXCLUDE]
        strongSelf.hideSpinner {
          if let error = error {
            strongSelf.showMessagePrompt(error.localizedDescription)
            return
          }
          strongSelf.navigationController?.popViewController(animated: true)
        }
        // [END_EXCLUDE]
      }

I expect the code to sign in an already existing user for firebase 我希望代码登录Firebase的现有用户

The documentation is accurate but what's in the getting started guide are just snippets of code. 该文档是准确的,但是入门指南中的内容只是代码片段。

You will need to take a look at the actual full code example to get the 'big picture'. 您将需要看一下实际的完整代码示例,以获取“全局”。 For example, this line 例如,这行

Auth.auth().removeStateDidChangeListener(handle!)

is being flagged as you've not defined a class var of handle. 被标记为您尚未定义handle的类变量。 What's shown in the getting started guide is a snippet. 入门指南中显示的是一个代码段。

在此处输入图片说明

You should click on the blue link (I circled in red) that take you to the actual full code example. 您应该单击蓝色链接(我用红色圈出),将您带到实际的完整代码示例。 When you do that, you'll see handle is defined as a class var 当您这样做时,您会看到handle被定义为一个类var

var handle: AuthStateDidChangeListenerHandle?

在此处输入图片说明

I think if you'll work through the actual full code example, those errors will go away. 我认为,如果您能完成实际的完整代码示例,这些错误将消失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM