One Logo Pool Ball
HealthKit · IOS API REFERENCE

HKAttachmentStore

class · iOS 16.0+ · SDK 27.1

class HKAttachmentStore

Members (8)

method · iOS 16.0+

getAttachments

TypeScript
getAttachments(object: HKObject, completion: ((arg0: (Array<HKAttachment>) | null, arg1: (NativeError) | null) => void)): void
Swift declaration
func attachments(for object: HKObject) async throws -> [HKAttachment]
method · iOS 16.0+

getData

TypeScript
getData(attachment: HKAttachment, completion: ((arg0: (ArrayBuffer) | null, arg1: (NativeError) | null) => void)): _Foundation_Progress
Swift declaration
func getData(for attachment: HKAttachment, completion: @escaping (Data?, (any Error)?) -> Void) -> Progress
init · iOS 16.0+

init

TypeScript
static init(healthStore: HKHealthStore): HKAttachmentStore
Swift declaration
init(healthStore: HKHealthStore)
method · iOS 16.0+

removeAttachment

TypeScript
removeAttachment(attachment: HKAttachment, object: HKObject, completion: ((arg0: boolean, arg1: (NativeError) | null) => void)): void
Swift declaration
func removeAttachment(_ attachment: HKAttachment, from object: HKObject) async throws
method · iOS 16.0+

streamData

TypeScript
streamData(attachment: HKAttachment, dataHandler: ((arg0: (ArrayBuffer) | null, arg1: (NativeError) | null, arg2: boolean) => void)): _Foundation_Progress
Swift declaration
func streamData(for attachment: HKAttachment, dataHandler: @escaping (Data?, (any Error)?, Bool) -> Void) -> Progress
method · iOS 16.0+

dataReader

TypeScript
dataReader(attachment: HKAttachment): HKAttachmentDataReader
Swift declaration
func dataReader(for attachment: HKAttachment) -> HKAttachmentDataReader

An HKAttachmentDataReader object for reading the given attachment's data.

method · iOS 16.0+

addAttachment

TypeScript
addAttachmentToNameContentTypeUrlMetadataCompletion(object: HKObject, name: string, contentType: _UniformTypeIdentifiers_UTType, url: string, metadata: Record<string, unknown>, completion: ((arg0: (HKAttachment) | null, arg1: (NativeError) | null) => void)): void
Swift declaration
@preconcurrency func addAttachment(to object: HKObject, name: String, contentType: UTType, url: URL, metadata: [String : Any] = [:], completion: @escaping @Sendable (HKAttachment?, (any Error)?) -> Void)

Creates a new `HKAttachment` using the passed in `URL` and attaches it to the specified `HKObject`. - Parameters - object: The object for which to add the `HKAttachment`. - name: The name of the attachment. - contentType: The Uniform Type of the file. - URL: The `URL` to use to create the attachment. - metadata: Extra information describing the attachment. - completion: Called with an HKAttachment instance once the file was successfully saved and attached, otherwise called with an error.

method · iOS 16.0+

addAttachment

TypeScript
addAttachmentToNameContentTypeUrlMetadata(object: HKObject, name: string, contentType: _UniformTypeIdentifiers_UTType, url: string, metadata?: Record<string, unknown>): Promise<HKAttachment>
Swift declaration
func addAttachment(to object: HKObject, name: String, contentType: UTType, url: URL, metadata: [String : Any] = [:]) async throws -> HKAttachment

Creates a new `HKAttachment` using the passed in `URL` and attaches it to the specified `HKObject`. - Parameters - object: The object for which to add the `HKAttachment`. - name: The name of the attachment. - contentType: The Uniform Type of the file. - URL: The `URL` to use to create the attachment. - metadata: Extra information describing the attachment. - Throws: `Error` if the attachment could not be saved. - Returns: An `HKAttachment` instance if the file was successfully saved and attached.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

HKAttachmentStore.init()

inherited init: cannot prove legal (class declares 1 custom initializer)

All HealthKit types →