Skip to content

Instantly share code, notes, and snippets.

@nebiros
Last active September 20, 2016 18:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nebiros/87b0fc3d52842f8ea55d9e8684f30ec4 to your computer and use it in GitHub Desktop.
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