Last active
July 8, 2017 19:04
-
-
Save gayapedro/ac49a8c5f761aec2c2af7b8f966e1e60 to your computer and use it in GitHub Desktop.
Busca DB Firebase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ViewController.swift | |
| // TesteFirebase | |
| // | |
| // Created by Pedro Gaya on 07/07/17. | |
| // Copyright © 2017 GayaSolutions. All rights reserved. | |
| // | |
| import UIKit | |
| import FirebaseDatabase | |
| class ViewController: UIViewController { | |
| @IBOutlet weak var labelPontuacao: UILabel! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // Do any additional setup after loading the view, typically from a nib. | |
| let database = Database.database().reference().child("usuarios") | |
| database.queryStarting(atValue: "Me", childKey: "nome").queryEnding(atValue: "Z"+"\u{F8FF}", childKey: "nome").queryOrdered(byChild: "nome").observe(DataEventType.value, with: { (dados) in | |
| for nomes in dados.children.allObjects as! [DataSnapshot] { | |
| let objeto = nomes.value as! [String: AnyObject] | |
| let idade = objeto["idade"]! | |
| let nome = objeto["nome"]! | |
| print("-----") | |
| print(idade) | |
| print (nome) | |
| print("-----") | |
| } | |
| }) | |
| } | |
| override func didReceiveMemoryWarning() { | |
| super.didReceiveMemoryWarning() | |
| // Dispose of any resources that can be recreated. | |
| } | |
| } | |
| let database = Database.database().reference().child("medicamentos") | |
| database.queryOrdered(byChild: "nome").observe(DataEventType.value, with: { (dados) in | |
| for nomes in dados.children.allObjects as! [DataSnapshot] { | |
| let objeto = nomes.value as! [String: AnyObject] | |
| let nome = objeto["nome"]! | |
| print("-----") | |
| print (nome) | |
| print("-----") | |
| } | |
| }) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"auth != null"