Snippets Collections
    override func viewDidLoad() {
        // function calling
        querySomething { (completed) in
              print("completed :", completed)
        }
    }
    
    func querySomething(completion: @escaping (Bool) -> Void) {
        let db = Firestore.firestore()
        db.collection("collectionName").document().addSnapshotListener { (documentSnapshot, error) in
            if error != nil {
                completion(false)
                return
            }
            completion(true)
        }
    }
star

Sat Apr 02 2022 04:49:10 GMT+0000 (Coordinated Universal Time)

#ios #swift #return #completion

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension