我在Swift中尝试以下完成块。但是,在Swift转换的代码中我得到了错误
预期','分隔符
我很久没能解决了。有人可以建议我解决这个错误吗?
的OBJ-C:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
[CoinbaseOAuth finishOAuthAuthenticationForUrl:url
clientId:kCoinbaseDemoClientID
clientSecret:kCoinbaseDemoClientSecret
completion:^(id result, NSError *error) {
}];
return YES;
}
夫特:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
CoinbaseOAuth.finishOAuthAuthenticationForUrl(url : NSURL!, kCoinbaseDemoClientID: String!, kCoinbaseDemoClientSecret: String!) {(AnyObject!, NSError!) -> Void in
println("Test message")
}
return true
}
答案 0 :(得分:2)
您应该按如下方式使用:
CoinbaseOAuth.finishOAuthAuthenticationForUrl(url, clientId: kCoinbaseDemoClientID, clientSecret: kCoinbaseDemoClientSecret, completion: { (result, error) -> Void in
println("Test message")
})
当您为completion
生成代码时,Xcode中存在一个错误,它会删除参数名称,并且您会收到该错误