Initializer

init(contentsOfFile:)

Initializes a newly allocated array with the contents of the file specified by a given path.

Declaration

convenience init?(contentsOfFile path: String)

Parameters

aPath

The path to a file containing a representation of an array produced by the write(toFile:atomically:) method.

Return Value

An array initialized to contain the contents of the file specified by aPath or nil if the file can’t be opened or the contents of the file can’t be parsed into an array. The returned object might be different than the original receiver.

Discussion

The array representation in the file identified by aPath must contain only property list objects (NSString, NSData, NSArray, or NSDictionary objects). The objects contained by this array are immutable, even if the array is mutable.

See Also

Initializing an Array

init()

Initializes a newly allocated array.

init(array: [Any])

Initializes a newly allocated array by placing in it the objects contained in a given array.

init(array: [Any], copyItems: Bool)

Initializes a newly allocated array using anArray as the source of data objects for the array.

init?(contentsOf: URL)

Initializes a newly allocated array with the contents of the location specified by a given URL.

Deprecated
init(objects: UnsafePointer<AnyObject>?, count: Int)

Initializes a newly allocated array to include a given number of objects from a given C array.