gpt4 book ai didi

ios - Swift 错误 : '(AFHTTPRequestOperation! , NSError? ) -> is not convertible to ' ((AFHTTPRequestOperation? , NSError) -> Void?

转载 作者:行者123 更新时间:2023-11-30 13:54:08 26 4
gpt4 key购买 nike

我正在 swift 中使用 AFNetworking,并且在将以下代码转换为 swift 时遇到问题

objective-c

[client GET:url parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {

} failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {

}];

Swift 代码(给出错误)

self.client.GET(url,
parameters: nil,
success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in

},
failure: { (operation: AFHTTPRequestOperation!, error: NSError!) in

})

最佳答案

这应该有效:

self.client.GET(url, parameters: nil, success: { (operation: AFHTTPRequestOperation, responseObject: AnyObject?) in

}, failure: { (operation: AFHTTPRequestOperation?, error: NSError) in

})

关于ios - Swift 错误 : '(AFHTTPRequestOperation! , NSError? ) -> is not convertible to ' ((AFHTTPRequestOperation? , NSError) -> Void?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33871037/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com