A mutable URL load request that is independent of protocol or URL scheme.
SDKs
- iOS 2.0+
- macOS 10.2+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Foundation
Declaration
@interface NSMutableURLRequest : NSURLRequest
Overview
NSMutable
is a subclass of NSURLRequest
that allows you to change the request’s properties.
NSMutable
only represents information about the request. Use other classes, such as NSURLSession
, to send the request to a server. See Fetching Website Data into Memory and Uploading Data to a Website for an introduction to these techniques.
Classes that create a network operation based on a request make a deep copy of that request. Thus, changing the request after creating a network operation has no effect on the ongoing operation. For example, if you use data
to create a data task from a request, and then later change the request, the data task continues using the original request.
Important
The Swift overlay to the Foundation framework provides the URLRequest
structure, which bridges to the NSMutable
class and its immutable superclass, NSURLRequest
. For more information about value types, see Working with Cocoa Frameworks in Using Swift with Cocoa and Objective-C (Swift 4.1).