我尝试构建一个应用,但出现命名错误。
import UIKit
import Firebase
class signupViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var ihrNameTextField: UITextField!
@IBOutlet weak var seinNameTextField: UITextField!
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var passwortTextField: UITextField!
@IBOutlet weak var erneutPasswortTextField: UITextField!
let picker = UIImagePickerController()
var userStorage: StorageReference!
override func viewDidLoad() {
super.viewDidLoad()
picker.delegate = self
let storage = Storage.storage().reference(forURL: "gs://hochzeitscountdown-38c20.appspot.com")
userStorage = storage.child("user")
}
@IBAction func selectImagePressed(_ sender: Any) {
picker.allowsEditing = true
picker.sourceType = .photoLibrary
present(picker, animated: true, completion: nil)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[UIImagePickerController.InfoKey.editedImage] as? UIImage {
self.imageView.image = image
}
self.dismiss(animated: true, completion: nil)
}
@IBAction func anmeldenPressed(_ sender: Any) {
guard ihrNameTextField.text != "", seinNameTextField.text != "", emailTextField.text != "", passwortTextField.text != "" else {return}
if passwortTextField.text == erneutPasswortTextField.text {
Auth.auth().createUser(withEmail: emailTextField.text!, password: passwortTextField.text!, completion: {(user, error) in
if let error = error {
print(error.localizedDescription)}
if let user = user {
let imageRef = self.userStorage.child("\(user.uid).jpg")
}
})
} else {
print("Passwörter sind nicht identisch.")
}
}
}
我仍然收到此错误:
'AuthDataResult'类型的值没有成员'uid'