dimanche 24 avril 2016

Retrieving data from firebase randomly. Swift

Hej, I am working on an application, and want to display some data from firebase. I need to do it randomly. My Firebase looks like this:

{
  "DictionaryRef" : {
    "Polish" : "English",
    "ad" : "asd",
    "asd" : "asd",
    "dfg" : "sf",
    "dsa" : "asd",
    "dsf" : "asd",
    "f" : "sa",
    "jabdfsdk" : "sd",
    "kajd,f" : "smdn f",
    "kasjf" : "sdnfm ",
    "kj" : "m",
    "kjdbf" : "bfdsfb",
    "sd;kfn" : "asmnd",
    "vgb" : " h",
    "vh" : "gh"
  }
}

It looks like dictionary, I want to retrieve some words from the left side in label.

    var myRootRef = Firebase(url:"http://ift.tt/23Sv9ZH")
    myRootRef.queryOrderedByKey().observeEventType(.ChildAdded, withBlock: {
        snapshot in
        if let Polish = snapshot.value["Polish"] as? String {
          self.QuestionLabel.text = Polish
       }
    })

It works, in this example it displays : English. but i do not want to write the name of the data, just to display my words in dictionary randomly.




Aucun commentaire:

Enregistrer un commentaire