2016-04-26 1 views
0

Wie erhält man die Antwort von einer Firebase-Anfrage? Also zum Beispiel eine Funktion starten, sobald ich den Kinderzählwert habe.Aufruf einer Funktion nach dem Empfang eines Werts aus der Firebase-Anforderung

let FAref = Firebase(url: "https://my-app.firebaseio.com/Users/\(uid!)/Data") 


    FAref.observeEventType(FEventType.Value, withBlock: { (snapshot) -> Void in 


     if snapshot != nil { 

      self.count = Int(snapshot.childrenCount) 

     } 


    }) { (error) -> Void in 
     print(error.description) 
    } 
+0

Was möchten Sie tun genau das tun? –

+0

Sobald ich die self.count = Int (snapshot.childrenCount) rufen Sie eine Funktion –

+0

Und was hält Sie davon ab? Sie können die Funktion einfach aufrufen, nachdem Sie 'self.count' gesetzt haben. –

Antwort

0
let FAref = Firebase(url: "https://my-app.firebaseio.com/Users/\(uid!)/Data") 


    FAref.observeEventType(FEventType.Value, withBlock: { (snapshot) -> Void in 


     if snapshot != nil { 

      let count = Int(snapshot.childrenCount) 

      //Just add the function call after you get the childrenCount 
      self.myFunction(count) 
     } 


    }) { (error) -> Void in 
     print(error.description) 
    }