Swift Firebase按下按钮获取下一个Child数据

时间:2018-04-08 16:59:38

标签: ios swift firebase firebase-realtime-database

如何通过按下按钮从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)
    }


}

0 个答案:

没有答案