I am trying to migrate my codes from swift 2 version to swift 3 version. I could not migrate following code part and I did not find any solution for it. How can I do it?
// MARK: URLRequestConvertible
public var URLRequest: NSMutableURLRequest {
let urlComponent = NSURLComponents(string: Router.baseURL)!
urlComponent.path = Router.basePath.stringByAppendingString(path)
let mutableURLRequest = NSMutableURLRequest(URL: urlComponent.URL!)
mutableURLRequest.HTTPMethod = method.rawValue
var parameters: [String: AnyObject] = Dictionary()
parameters["key"] = Router.key
parameters["hl"] = "en"
switch self {
case .getMostPopularVideos(let pageToken):
parameters["part"] = "snippet,contentDetails,statistics"
parameters["chart"] = "mostPopular"
parameters["videoCategoryId"] = TubeTrends.Settings.topTrendsCat
if let pageToken = pageToken {
parameters["pageToken"] = pageToken
}
return Alamofire.ParameterEncoding.URL.encode(mutableURLRequest, parameters: parameters).0 //This part Giving Error like Alamofire Type 'ParameterEncoding' has no member 'URL'
// default:
// return mutableURLRequest
}
}
}
I'd change the name of this computed property to, say,
request
, to avoid clashing with the new type name,URLRequest
. Coincidentally, this computed property should use a type ofURLRequest
:Looks like a lot has changed in Swift 3. Try to change your code by taking reference as below code.