<!--
{
  "availability" : [
    "macOS: 13.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreSpotlight",
  "identifier" : "/documentation/CoreSpotlight/CSSearchableIndex/fetchData(forBundleIdentifier:itemIdentifier:contentType:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Spotlight",
      "CoreSpotlight"
    ],
    "preciseIdentifier" : "c:objc(cs)CSSearchableIndex(im)fetchDataForBundleIdentifier:itemIdentifier:contentType:completionHandler:"
  },
  "title" : "fetchData(forBundleIdentifier:itemIdentifier:contentType:completionHandler:)"
}
-->

# fetchData(forBundleIdentifier:itemIdentifier:contentType:completionHandler:)

Fetches data from an external provider.

```
func fetchData(forBundleIdentifier bundleIdentifier: String, itemIdentifier: String, contentType: UTType, completionHandler: @escaping @Sendable (Data?, (any Error)?) -> Void)
```

## Parameters

`bundleIdentifier`

The bundle identifier of the app to search.

`itemIdentifier`

The app-specific identifier of the item you want.

`contentType`

The type of data to fetch.

`completionHandler`

The block to execute with the results. The block
has no return value and takes the following parameters:

- data: The data for the specified item, if successful.
- error: An error object, or `nil` if the method retrieved the data successfully.

## Discussion

Clients with the appropriate entitlements can use this method to fetch data
from an external app such as Mail.

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> func fetchData(forBundleIdentifier bundleIdentifier: String, itemIdentifier: String, contentType: UTType) async throws -> Data
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

---

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)