Type Method

dataWithContentsOfFile:

Creates a data object by reading every byte from the file at a given path.

Declaration

+ (instancetype)dataWithContentsOfFile:(NSString *)path;

Parameters

path

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

Discussion

This method returns nil if the data object could not be created. If you need to know the reason for failure, use dataWithContentsOfFile:options:error:.

This method is equivalent to calling dataWithContentsOfFile:options:error: and passing no options.

A sample using this method can be found in Working With Binary Data.

See Also

Reading Data from a File

+ dataWithContentsOfFile:options:error:

Creates a data object by reading every byte from the file at a given path.

+ dataWithContentsOfURL:

Creates a data object containing the data from the location specified by a given URL.

+ dataWithContentsOfURL:options:error:

Creates a data object containing the data from the location specified by a given URL.

- initWithContentsOfFile:

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

- initWithContentsOfFile:options:error:

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

- initWithContentsOfURL:

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

- initWithContentsOfURL:options:error:

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

NSDataReadingOptions

Options for methods used to read data objects.

- initWithContentsOfMappedFile:

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

Deprecated
+ dataWithContentsOfMappedFile:

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

Deprecated