I was wondering what the difference is between setting the header value and adding the header value in NSMutableURLRequest. That sounds obvious, but for example, can't you just use addValue every time? Will setting a header that does not exist produce an error? Will adding a header, when it already exists in the request, overwrite the existing value?
Example
let request.NSMutableURLRequest(URL: NSURL(string: "someURL")!)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
...
source
share