Swift 3 – Resolving method ambiguity defining closures as a var
// objc's continue method signature: - (AWSTask *)continueWithBlock:(AWSContinuationBlock)block; | |
// swift translate it as: .continue(block: (AWSTask<AWSCognitoIdentityUserPoolSignUpResponse>) -> Any?) | |
// error: Ambiguous use of 'continue' | |
pool.signUp(username, | |
password: password, | |
userAttributes: attrs, | |
validationData: nil) | |
.continue { (task) -> Any? in | |
} | |
// typealias to the rescue… | |
typealias SignUpContinueClosure = (AWSTask<AWSCognitoIdentityUserPoolSignUpResponse>) -> (Any?) | |
var signUpContinueClosure: SignUpContinueClosure = { (task) in | |
return nil | |
} | |
// YAY!, no error! | |
pool.signUp(username, | |
password: password, | |
userAttributes: attrs, | |
validationData: nil) | |
.continue(signUpContinueClosure) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment