Skip to content

Instantly share code, notes, and snippets.

@nebiros nebiros/test1.swift
Last active Sep 20, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.