NowAttachment structure - iOS
The NowAttachment structure provides functions that enable you to validate attachments by comparing their computed hash.
|
Name |
Type |
Description |
|---|---|---|
|
data |
Data |
Attachment data. |
|
hash |
String |
Computed digest for the attachment data.This computed digest is used to validate the attachment by comparing it to the known digest stored in the attachment metadata. Calculating the computed digest is expensive; avoid using it in the UI. Instead, consider using the hash property in the NowAttachmentMetadata class. If you must use the computed hash, use it sparingly, and consider caching it. |
|
metadata |
Metadata associated with the attachment. |
NowAttachment - validate()
Validates the attachment by comparing the computed hash for the attachment data to the digest stored in the attachment metadata.
| Name | Type | Description |
|---|---|---|
| None |
|
Type |
Description |
|---|---|
|
Boolean |
Flag that indicates whether the attachment is valid.Possible values:
|
guard let metadataHeader = response.httpResponse?.value(forHTTPHeaderField: NowAttachment.attachmentMetadataHeaderKey), let metadataHeaderData = metadataHeader.data(using: .utf8) else { throw NowDataError.missingAttachmentMetadata } let metadata = try coder.decode(NowAttachmentMetadata.self, from: metadataHeaderData)let attachment = NowAttachment(metadata: metadata, data: response.data) if !attachment.validate() { throw NowDataError.attachmentValidation}// Attachment is validreturn attachment---
title: NowAttachment structure - iOS
description: The NowAttachment structure provides functions that enable you to validate attachments by comparing their computed hash.Validates the attachment by comparing the computed hash for the attachment data to the digest stored in the attachment metadata.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/cllent-mobile-api-reference/NowAttachmentiOSStructure.html
release: australia
product: Cllent Mobile API Reference
classification: cllent-mobile-api-reference
topic_type: concept
last_updated: "2026-09-10"
reading_time_minutes: 1
breadcrumb: [Mobile SDK - iOS, Mobile SDK API reference, API reference, API implementation and reference]
---
# NowAttachment structure- iOS
The NowAttachment structure provides functions that enable you to validate attachments by comparing their computed hash.
<table id="table_vx2_klw_5pb" class="parameters"><thead><tr><th>
Name
</th><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
data
</td><td>
Data
</td><td>
Attachment data.
</td></tr><tr><td>
hash
</td><td>
String
</td><td>
Computed digest for the attachment data.This computed digest is used to [validate](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/NowAttachmentiOSStructure.md) the attachment by comparing it to the known digest stored in the [attachment metadata](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/NowAttachmentMetadataiOSStructure.md). Calculating the computed digest is expensive; avoid using it in the UI. Instead, consider using the hash property in the [NowAttachmentMetadata](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/NowAttachmentMetadataiOSStructure.md) class. If you must use the computed hash, use it sparingly, and consider caching it.
</td></tr><tr><td>
metadata
</td><td>
[NowAttachmentMetadata](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/NowAttachmentMetadataiOSStructure.md)
</td><td>
Metadata associated with the attachment.
</td></tr></tbody>
</table>**Parent Topic:**[Mobile SDK - iOS](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/cllent-mobile-api-reference/MobileSDKiOSAPI.md)
## NowAttachment - validate\(\)
Validates the attachment by comparing the computed hash for the attachment data to the digest stored in the attachment metadata.
|Name|Type|Description|
|----|----|-----------|
|None| | |
<table id="table_pvt_cgr_5pb" class="returns"><thead><tr><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
Boolean
</td><td>
Flag that indicates whether the attachment is valid.Possible values:
- true: Attachment is valid.
- false: Attachment is invalid.
</td></tr></tbody>
</table>The following code example shows how to call this function.
```
guard
let metadataHeader = response.httpResponse?.value(forHTTPHeaderField: NowAttachment.attachmentMetadataHeaderKey),
let metadataHeaderData = metadataHeader.data(using: .utf8) else {
throw NowDataError.missingAttachmentMetadata
}
let metadata = try coder.decode(NowAttachmentMetadata.self, from: metadataHeaderData)
let attachment = NowAttachment(metadata: metadata, data: response.data)
if !attachment.validate() {
throw NowDataError.attachmentValidation
}
// Attachment is valid
return attachment
```
| title | NowAttachment structure - iOS |
| description | The NowAttachment structure provides functions that enable you to validate attachments by comparing their computed hash.Validates the attachment by comparing the computed hash for the attachment data to the digest stored in the attachment metadata. |
| locale | en-US |
| canonical_url | https://www.servicenow.com/docs/r/australia/api-reference/cllent-mobile-api-reference/NowAttachmentiOSStructure.html |
| release | australia |
| product | Cllent Mobile API Reference |
| classification | cllent-mobile-api-reference |
| topic_type | concept |
| last_updated | 2026-09-10 |
| reading_time_minutes | 1 |
| breadcrumb | Mobile SDK - iOSMobile SDK API referenceAPI referenceAPI implementation and reference |