我是使用Firebase的新手,我一直在尝试关注在线教程。但是,我一直收到错误:
var ref = DatabaseReference.database()。reference()
错误如下:"实例成员数据库不能用于类型' DatabaseReference'。"
我错过了什么或做错了什么?任何帮助将不胜感激!
import UIKit
import Firebase
import FirebaseDatabase
class ViewController: UIViewController {
@IBOutlet weak var myTextField: UITextField!
var ref: DatabaseReference?
@IBAction func saveButton(_ sender: Any) {
var ref = DatabaseReference.database().reference()
if myTextField.text != ""
{
ref?.child("list").childByAutoId().setValue(myTextField.text)
myTextField.text = ""
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
答案 0 :(得分:1)
根据the documentation,它应该是Database.database().reference()
。
DatabaseReferenece
没有成员database().reference()
。