<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "BackgroundAssets",
  "identifier" : "/documentation/BackgroundAssets/AssetPackManager/contents(at:asLocalizedFor:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Background Assets"
    ],
    "preciseIdentifier" : "s:16BackgroundAssets16AssetPackManagerC8contents2at14asLocalizedFor7options10Foundation4DataV6System8FilePathV_AH6LocaleV8LanguageVSo20NSDataReadingOptionsVtKF"
  },
  "title" : "contents(at:asLocalizedFor:options:)"
}
-->

# contents(at:asLocalizedFor:options:)

Returns the contents of a localized asset file at the specified relative path.

```
nonisolated func contents(at path: FilePath, asLocalizedFor language: Locale.Language, options: Data.ReadingOptions = .mappedIfSafe) throws -> Data
```

## Parameters

`path`

The relative path.

`language`

The language that the framework uses to limit the search within localized asset packs.

`options`

Options for how to read the file’s contents into a `Data` instance.

## Return Value

The file’s contents.

## Discussion

All asset packs share the same namespace, so you can treat the overall collection of downloaded asset packs as if it were a single root directory that contains all of your subdirectories and asset files, regardless of the specific asset pack in which any particular file resides. This method searches in only the downloaded asset packs that are localized in the specified language. If there’s a file-path collision across multiple such asset packs, then it’s undefined from which asset pack the file will be read.

This method is most useful if you intentionally induce a file-path collision across multiple differently localized asset packs. For example, you may include an English-localized version of `Videos/Introduction.m4v` in an `en` asset pack, a Hebrew-localized version of `Videos/Introduction.m4v` in a `he` asset pack, and an American Spanish–localized version of `Videos/Introduction.m4v` in an `es-US` asset pack. If you offer split-language functionality to users, then you may want to download two or more of those asset packs on the same device. In that scenario, the specific choice of file that [`contents(at:searchingInAssetPackWithID:options:)`](/documentation/BackgroundAssets/AssetPackManager/contents(at:searchingInAssetPackWithID:options:)) reads would be undefined unless you determine the appropriate asset pack’s ID and pass it to that method’s `assetPackID` parameter. With this method, merely passing a `Locale.Language` instance to the `language` parameter is sufficient to resolve the ambiguity without requiring that you determine the asset pack’s ID. [`contents(at:searchingInAssetPackWithID:options:)`](/documentation/BackgroundAssets/AssetPackManager/contents(at:searchingInAssetPackWithID:options:)) is more suitable in most other situations.

> Note: Language matching considers implicit script and region tags per Unicode’s Common Locale Data Repository. For example, `en` is equivalent to `en-US` and `en-Latn-US` but not `en-CA`.

> Throws: ``doc://com.apple.backgroundassets/documentation/BackgroundAssets/ManagedBackgroundAssetsError/fileNotFound(at:)`` when no file is found at `path`.

> Throws: When the path is not relative or when some other error occurs while finding or reading the requested file.

---

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)