<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "BackgroundAssets",
  "identifier" : "/documentation/BackgroundAssets/BAAssetPackManager/contentsAtPath:searchingInAssetPackWithIdentifier:options:error:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Background Assets"
    ],
    "preciseIdentifier" : "c:objc(cs)BAAssetPackManager(im)contentsAtPath:searchingInAssetPackWithIdentifier:options:error:"
  },
  "title" : "contentsAtPath:searchingInAssetPackWithIdentifier:options:error:"
}
-->

# contentsAtPath:searchingInAssetPackWithIdentifier:options:error:

Returns the contents of an asset file at the specified relative path.

```
- (NSData *) contentsAtPath:(NSString *) path searchingInAssetPackWithIdentifier:(NSString *) assetPackIdentifier options:(NSDataReadingOptions) options error:(NSError **) error;
```

## Parameters

`path`

The relative file path.

`assetPackIdentifier`

The identifier of the asset pack in which you want to search for the file or `nil` if you want to search in all asset packs.

`options`

Options for how to read the file’s contents into a data object.

`error`

A pointer to an error that will be set if an error occurs. If no file is found at `path`, then `error` will point to an `NSError` object with [`BAManagedErrorCodeFileNotFound`](/documentation/BackgroundAssets/BAManagedErrorCode/BAManagedErrorCodeFileNotFound) as its code.

## Return Value

The file’s contents or `nil` if an error occurred.

## 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. If there’s a file-path collision across multiple asset packs, then it’s undefined from which asset pack the file will be read unless you explicitly limit the search to a particular asset pack by passing a non-`nil` identifier to the `assetPackIdentifier` parameter.

---

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)