<!--
{
  "availability" : [
    "iOS: 2.0.0 - 27.2.0",
    "iPadOS: 2.0.0 - 27.2.0",
    "macCatalyst: 13.1.0 - 27.2.0",
    "macOS: 10.0.0 - 27.2.0",
    "tvOS: 9.0.0 - 27.2.0",
    "visionOS: 1.0.0 - 27.2.0",
    "watchOS: 2.0.0 - 27.2.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSArray/init(contentsOf:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSArray(im)initWithContentsOfURL:"
  },
  "title" : "init(contentsOf:)"
}
-->

# init(contentsOf:)

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

```
convenience init?(contentsOf url: URL)
```

## Parameters

`url`

The location of a file containing a string representation of an array produced by the
`writeToURL: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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)