bytes
An asynchronous sequence that provides the attachment’s data.
Declaration
var bytes: HKAttachment.AsyncBytes { get }Discussion
Use this property to access the file’s contents as an asynchronous sequence of bytes.
// Asynchronously access the attachment's bytes.
var data = Data()
do {
for try await byte in dataReader.bytes {
// Use the bytes here.
data.append(byte)
}
} catch {
// Handle the error here.
fatalError("*** An error occurred while reading the attachment's data: \(error.localizedDescription) ***")
}