Initializer

init(contentsOf:)

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

Declaration

convenience init?(contentsOf url: URL)

Parameters

aURL

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

Return Value

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

Discussion

The array representation at the location identified by aURL 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?(contentsOfFile: String)

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

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

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