---
title: "getAttachments(for:completion:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkattachmentstore/getattachments(for:completion:)"
---

# getAttachments(for:completion:)

Returns all the attachments for the specified object.

## Declaration

```swift
func getAttachments(for object: HKObject, completion: @escaping @Sendable ([HKAttachment]?, (any Error)?) -> Void)
```

```swift
func attachments(for object: HKObject) async throws -> [HKAttachment]
```

## Parameters

- `object`: An object from the HealthKit store.
- `completion`: A completion handler that the system calls to return the attachment. This handler takes the following parameters:

## Discussion

Discussion Call this method to get all the attachments for the specified object. let attachments: [HKAttachment] do {     attachments = try await attachmentStore.attachments(for: prescription) } catch {     // Handle the error here.     fatalError("*** An error occurred while accessing the attachments for a prescription: \(error.localizedDescription) ***") }

// Use the attachments here.

## See Also

### Accessing attachments

- [dataReader(for:)](healthkit/hkattachmentstore/datareader(for:).md)
- [getData(for:completion:)](healthkit/hkattachmentstore/getdata(for:completion:).md)
- [streamData(for:dataHandler:)](healthkit/hkattachmentstore/streamdata(for:datahandler:).md)
