I am using AFNetworking in swift and i am facing a problem in converting following code to swift
Objective C
[client GET:url parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) {
} failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
}];
Swift Code (gives error)
self.client.GET(url,
parameters: nil,
success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) in
},
failure: { (operation: AFHTTPRequestOperation!, error: NSError!) in
})
This should work:
self.client.GET(url, parameters: nil, success: { (operation: AFHTTPRequestOperation, responseObject: AnyObject?) in
}, failure: { (operation: AFHTTPRequestOperation?, error: NSError) in
})