我已经在 objC 中创建了成功和失败 block ,并且我正在尝试在 swift 中使用该函数。出现错误,我陷入困境,请帮助我。
objective-c :
-(void)registerAppWithSuccessBlock:(void (^)(id responseObject))success andFailureBlock:(void (^)(NSError *error))failure{}
我正在快速调用相同的函数,它显示错误。
swift :
USSecService.sharedInstance().registerAppWithSuccessBlock({(responseObject : AnyObject) -> Void in{code}
}, andFailureBlock: { (error : NSError) -> Void in {code}
})
收到此错误:
Cannot invoke 'registerAppWithSuccessBlock' with an argument list of type '((AnyObject) -> Void, andFailureBlock: (NSError) -> Void)'
最佳答案
USSecService.sharedInstance().registerAppWithSuccessBlock({ (responseObject) -> Void in
print("Success")
}, andFailureBlock: { (error) -> Void in
print("Failure")
})
关于ios - 用 Objective C 编写的成功和失败 block ,在 swift 中显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33891163/