Contents

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