Kex
Kex

Reputation: 8589

Issue doing parameter encoding with Alamofire 4.0

Trying to convert a code base for Swift 3.0 Currently using

return (Alamofire.ParameterEncoding.URL.encode(mutableURLRequest, parameters: nil).0, uploadData)

Where:

let mutableURLRequest = NSMutableURLRequest(url: URL(string: urlString)!)

Have the error "ParameterEncoding has no member URL". Also tried

return (Alamofire.ParameterEncoding.encode(mutableURLRequest).0, uploadData) and the doesn't work. Any ideas how to fix this? Any pointers would be really appreciated! Thanks!

Upvotes: 1

Views: 513

Answers (1)

SHISHIR R AMIN
SHISHIR R AMIN

Reputation: 412

Alamofire has a struct URLEncoding, which confirms to the ParameterEncoding protocol.

    var urlRequest:URLRequest? = nil
    do {
        try   urlRequest =  Alamofire.URLEncoding().encode(mutableURLRequest, with: parameters)
    } catch {

    }
    return urlRequest!

Upvotes: 3

Related Questions