2016-09-18 116 views
0

我剛剛更新了我的Xcode到Xcode8和我已經轉換該項目以迅速3.轉換爲斯威夫特3(斯威夫特和火力地堡項目)

在簽到功能在這裏:

Firth. Auth()?.signIn(withEmail: self.EmailTF.text!, password: self.PasswordTF.text!, completion: { (user: FIRUser?, error: NSError?) in 
         if let error = error { 
          print(error.localizedDescription) 
         } else { 

          self.ref.child("UserProfile").child(user!.uid).setValue([ 
           "email": self.EmailTF.text!, 
           "name" : self.NameTF.text!, 
           "phone": self.PhoneTF.text!, 
           "city" : self.CityTF.text!, 
           ]) 
          print("Sucess") 

         } 
        }) 

我得到這個錯誤:

cannot convert value of type '(FIRUser?, NSError?) ->()' to expected argument type 'FIRAuthResultCallback?' 

在swift 3中它有什麼替代?

回答

3

只需將其替換爲: -

FIRAuth.auth()?.signIn(withEmail:self.EmailTF.text!, password: self.PasswordTF.text!, completion: { (user, err) in 
     if let error = err { 
         print(error.localizedDescription) 
        } else { 

         self.ref.child("UserProfile").child(user!.uid).setValue([ 
          "email": self.EmailTF.text!, 
          "name" : self.NameTF.text!, 
          "phone": self.PhoneTF.text!, 
          "city" : self.CityTF.text!, 
          ]) 
         print("Sucess") 

        } 
    }) 
+0

可以使用尾隨符號。這使得閱讀更簡單。 '.signIn(withEmail:「dasd」,密碼:「qwewqe」){...}'https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Closures.html#// apple_ref/doc/uid/TP40014097-CH11-ID102 – BennX

+0

太好了,謝謝你的提示!將檢查鏈接。 – Mariah

+0

@瑪利亞沒有,這應該很好。@ BennX你到底想說什麼?要使用'completionBlocks:'?哪裏?這是預定義的Firebase身份驗證功能。對不起,我只是沒有得到你..請詳細說明 – Dravidian