Initializer

init(contentsOfFile:options:)

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

Declaration

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

Parameters

path

The absolute path of the file from which to read data.

mask

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

errorPtr

If an error occurs, upon return contains an NSError object that describes the problem.

Return Value

A data object initialized by reading into it the data from the file specified by path.

Discussion

See Also

Reading Data from a File

init?(contentsOfFile: String)

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

init?(contentsOf: URL)

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

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

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

struct NSData.ReadingOptions

Options for methods used to read data objects.

init?(contentsOfMappedFile: String)

Initializes a data object with the contents of the mapped file specified by a given path.

Deprecated
class func dataWithContentsOfMappedFile(String)

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

Deprecated