google / google/promises

Cannot convert value of type 'Promise<Any>' to expected argument type '(Any) throws -> Void' Error in Swift

Open
#129 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Objective-C
Stars
3.8k
Forks
316
PR merge metrics
No merged PRs in 30d

Description

` getAllUsers(gsuiteName: gsuiteName).then(uploadUsers(arr1: currentUsersEM,arr2: currentUsersUS)).then(newScreen())`

Am trying to use this library for the first time and am running into this error when chaining promises together:

> Cannot convert value of type 'Promise' to expected argument type '(Any) throws -> Void' Error in Swift

Here is the code for getAllUsers() and uploadUsers():
` func getAllUsers(gsuiteName: String) -> Promise{

Database.database().reference().child("Messages").child(gsuiteName).child("USERS").observe(.value) { (snapshot) in
//when(
for child in snapshot.children{
self.currentUsersEM.append((child as AnyObject).value as String)
self.currentUsersUS.append((child as AnyObject).key as String)
}
self.currentUsersEM.append((Auth.auth().currentUser?.email)!)
self.currentUsersUS.append(self.username.text!)
}
return Promise {
return nil
}
}
func uploadUsers(arr1: Array, arr2: Array) -> Promise{
for usCount in 0..<(arr1.count){
print("USERNAME\(arr1[usCount] as! String)")
print("EMAIL\(arr2[usCount] as! String)")
//Database.database().reference().child("Messages").child(gsuiteName).child("USERS").setValue([currentUsersUS[usCount] as! String :currentUsersEM[usCount] as! String])
}
return Promise{
return nil
}
}
func newScreen(){
let changeRequest = Auth.auth().currentUser?.createProfileChangeRequest()
changeRequest?.displayName = self.username.text
changeRequest?.commitChanges { (error) in
self.performSegue(withIdentifier: "goToChat", sender: self)
//}
}
}`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.