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

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

我在 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

})