Firebase completion listeners in swift

后端 未结 3 1023
夕颜
夕颜 2020-12-18 13:38

How do you execute a completion listener for firebase in swift? It says there are completion listers for SetValue and UpdateValue in the docs but there is no example.

3条回答
  •  遥遥无期
    2020-12-18 14:04

    An example of using completion handler for setValue in firebase is given below. Similarly you can use completion handler for methods.

        func saveJob(completion:(Bool)-> Void) {
        FIRDatabase.database().reference().child("Job").setValue(["Title":self.title!,"Detail":self.details!], withCompletionBlock: { (error, ref) in
            debugPrint("Completed")
            completion(true)
        })
    }
    

提交回复
热议问题