如何通过按下按钮从firebase数据库获取下一个子数据?
import UIKit
导入Firebase
类ViewController:UIViewController {
var ref: DatabaseReference!
@IBOutlet weak var textLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
ref = Database.database().reference()
ref.child("motivator").child("spruche").observeSingleEvent(of: .value, with: { (snapshot) in
// Get user value
let value = snapshot.value as? NSDictionary
let username = value?["spruche1"] as? String ?? ""
self.textLabel.text = username
// ...
}) { (error) in
print(error.localizedDescription)
}
}