Type Method

arrayWithContentsOfFile:

Creates and returns an array containing the contents of the file specified by a given path.

Declaration

+ (NSArray<ObjectType> *)arrayWithContentsOfFile:(NSString *)path;

Parameters

aPath

The path to a file containing a string representation of an array produced by the writeToFile:atomically: method.

Return Value

An array containing the contents of the file specified by aPath. Returns nil if the file can’t be opened or if the contents of the file can’t be parsed into an array.

Discussion

The array representation in the file identified by aPath must contain only property list objects (NSString, NSData, NSDate, NSNumber, NSArray, or NSDictionary objects). For more details, see Property List Programming Guide. The objects contained by this array are immutable, even if the array is mutable.

See Also

Creating an Array

+ array

Creates and returns an empty array.

+ arrayWithArray:

Creates and returns an array containing the objects in another given array.

+ arrayWithContentsOfURL:

Creates and returns an array containing the contents specified by a given URL.

Deprecated
+ arrayWithObject:

Creates and returns an array containing a given object.

+ arrayWithObjects:

Creates and returns an array containing the objects in the argument list.

+ arrayWithObjects:count:

Creates and returns an array that includes a given number of objects from a given C array.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software