【发布时间】:2016-03-13 00:24:28
【问题描述】:
我目前正在尝试将 Venmo-iOS-SDK 用于我正在开发的应用程序。 SDK 在 Objective-C 中,而我正在尝试将它与 swift 应用程序一起使用。
我在将完成 obj-c 块的语法转换为 swift 时遇到问题。我找到了实现我想使用的功能的示例代码。
- (IBAction)logInButtonAction:(id)sender {
[[Venmo sharedInstance] requestPermissions:@[VENPermissionMakePayments,
VENPermissionAccessProfile]
withCompletionHandler:^(BOOL success, NSError *error) {
if (success) {
NSLog("Success")
} else {
NSLog("Failure")
}
}];
}
我试过这样做
@IBAction func loginButtonAction(sender: AnyObject){
Venmo.sharedInstance().requestPermissions([VENPermissionMakePayments, VENPermissionAccessPhone], withCompletionHandler: { (success: Bool, error: NSErrorPointer) -> Void in
if success{
println("Yes")
}else{
println("No")
}
})
}
但得到错误
"不能使用类型参数列表调用 'requestsPermissions '([String], withCompletionHandler: (Bool, NSError) -> Void)'
这是我如何翻译块的问题吗?或者是其他东西。查看 Venmo-SDK,obj-C 函数是这样定义的
- (void)requestPermissions:(NSArray *)permissions withCompletionHandler:(VENOAuthCompletionHandler)handler;
和
- (void)requestPermissions:(NSArray *)permissions withCompletionHandler:(VENOAuthCompletionHandler)handler;
【问题讨论】:
标签: ios swift objective-c-blocks venmo