tidwall
tidwall

Reputation: 6949

How to convert NSURLRequest to NSMutableURLRequest in Swift 3?

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.

Upvotes: 9

Views: 9768

Answers (1)

tidwall
tidwall

Reputation: 6949

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

let mreq = req.mutableCopy() as! NSMutableURLRequest

becomes

var mreq = req

Upvotes: 17

Related Questions