I updated from Swift 3 to 4, and i am using RxSwift, When updated i came across an error "Extra argument in call" as it expects now of type element. I tried creating tuple of (response, data) but still gives me an error as shown.
public static func deleteCrush(receiver: String, receiver_type: ProviderType) -> Observable<(HTTPURLResponse, NSArray)> {
/*
Delete crush identified by `id`
*/
let parameters: Parameters = [
"receiver": receiver,
"receiver_type": receiver_type.rawValue
]
print("deleteCrush paramreters: \(parameters)")
return Observable.create({ (observer) -> Disposable in
Alamofire.request(Router.deleteCrush(parameters: parameters))
.rx
.responseJSON()
.debug()
.subscribe(onNext: { (response, json) in
print("deleteCrush response code: ", response.statusCode)
if let data = json as? NSArray {
observer.on(.next(response, data))
observer.on(.completed)
}
}, onError: { (error) in
print("deleteCrush error: ", error)
observer.on(.error(error))
}, onCompleted: nil, onDisposed: nil)
})
}
Error: Extra argument in call.
After trying to fix:
var tuple = (response, json)
if let data = json as? NSArray {
observer.on(.next(tuple))
observer.on(.completed)
}
Error:
Event<(HTTPURLResponse, NSDictionary)>' produces result of type 'Event', but context expects 'Event<(HTTPURLResponse, NSDictionary)>