return url from completion

PHOTO EMBED

Sat Apr 02 2022 04:49:10 GMT+0000 (UTC)

Saved by @hasnat #ios #swift #return #completion

    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)
        }
    }
content_copyCOPY