我刚开始在iOS上使用Firebase Database
。我已使用firebase
为iOS完全设置了cocoaPods
。但是,该文本不显示从数据库检索到的文本。它在运行后只是显示为空。我怎么了?
class AppreciationViewController: UIViewController {
var ref: DatabaseReference!
@IBOutlet weak var otherAppreciation: UILabel!
@IBOutlet weak var support: UILabel!
@IBOutlet weak var body: UILabel!
@IBOutlet weak var contact: UILabel!
@IBOutlet weak var body2: UILabel!
@IBOutlet weak var dedication: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
ref = Database.database().reference(); ref.child("Appreciation").child("body2").observe(.value) { (snapshot) in
let body2String = snapshot.value as? String
self.body2.text = body2String
}
ref.child("Appreciation").child("contact").observe(.value) { (snapshot) in
let contactString = snapshot.value as? String
self.contact.text = contactString
}
ref.child("Appreciation").child("dedication").observe(.value) { (snapshot) in
let dedicationString = snapshot.value as? String
self.dedication.text = dedicationString
}
ref.child("Appreciation").child("otherAppreciation").observe(.value) { (snapshot) in
let otherAppreciationString = snapshot.value as? String
self.otherAppreciation.text = otherAppreciationString
}
ref.child("Appreciation").child("body").observe(.value) { (snapshot) in
let bodyString = snapshot.value as? String
self.body.text = bodyString
}
ref.child("Appreciation").child("support").observe(.value) { (snapshot) in
let supportString = snapshot.value as? String
self.support.text = supportString
}
}
}