Initializer

init(contentsOf:options:)

Returns a data object initialized with the data from the location specified by a given URL.

Declaration

init(contentsOf url: URL, options readOptionsMask: NSData.ReadingOptions = []) throws

Parameters

aURL

The URL from which to read data.

mask

A mask that specifies options for reading the data. Constant components are described in NSData.ReadingOptions.

errorPtr

If there is an error reading in the data, upon return contains an NSError object that describes the problem.

Return Value

A data object initialized with the data from the location specified by aURL. The returned object might be different than the original receiver.

Discussion

See Also

Reading Data from File

init?(contentsOfFile: String)

Returns a data object initialized with the content of the file at a given path.

init(contentsOfFile: String, options: NSData.ReadingOptions = [])

Returns a data object initialized with the content of the file at a given path.

init?(contentsOf: URL)

Initializes a newly allocated data object with the data from the location specified by a given URL.

struct NSData.ReadingOptions

Options for methods used to read data objects.

class func dataWithContentsOfMappedFile(String)

Creates and returns a data object from the mapped file at a given path.

Deprecated
init?(contentsOfMappedFile: String)

Returns a data object initialized by reading into it the mapped file specified by a given path.

Deprecated