Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert NSURLRequest to NSMutableURLRequest in Swift 3?

Tags:

swift3

I'm in the process of migrating one of my projects to Swift 3 and I'm hung up on converting a NSURLRequest to NSURLMutableRequest. In Swift 2 I could simply:

let mreq = req.mutableCopy() as! NSMutableURLRequest

But now mutableCopy is no longer a thing in Swift 3. I tried various permutations of constructors and looked in the docs for info to no avail. I must be missing something. There has to be a way to make a mutable copy of an object.

like image 538
tidwall Avatar asked Jul 02 '16 14:07

tidwall


1 Answers

I just figured it out. Dang it was too obvious.

let mreq = req.mutableCopy() as! NSMutableURLRequest

becomes

var mreq = req
like image 105
tidwall Avatar answered Jan 03 '23 15:01

tidwall