<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/CMSEncoderSetHasDetachedContent(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@CMSEncoderSetHasDetachedContent"
  },
  "title" : "CMSEncoderSetHasDetachedContent(_:_:)"
}
-->

# CMSEncoderSetHasDetachedContent(_:_:)

Specifies whether the signed data is to be separate from the message.

```
func CMSEncoderSetHasDetachedContent(_ cmsEncoder: CMSEncoder, _ detachedContent: Bool) -> OSStatus
```

## Parameters

`cmsEncoder`

The CMSEncoder reference returned by the [`CMSEncoderCreate(_:)`](/documentation/Security/CMSEncoderCreate(_:)) function.

`detachedContent`

`TRUE` if the message should exclude the data to be signed. Prior to calling this function, the encoder defaults to `FALSE` for this setting, indicating that the message contains the data to be signed.

## Return Value

A result code. See [Security Framework Result Codes](/documentation/Security/security-framework-result-codes).

## Discussion

A signed CMS message can optionally be sent separately from the signed data. Set `detachedContent` to `TRUE` to indicate that the signed data is to be kept separate from the message.

Encrypted messages, including those that are also signed, cannot use detached content.

If you do call this function, you must call it before the first call to the [`CMSEncoderUpdateContent(_:_:_:)`](/documentation/Security/CMSEncoderUpdateContent(_:_:_:)) function.

## See Also

[`CMSEncoderGetHasDetachedContent(_:_:)`](/documentation/Security/CMSEncoderGetHasDetachedContent(_:_:))

Indicates whether the message is to have detached content.

[`CMSEncoderUpdateContent(_:_:_:)`](/documentation/Security/CMSEncoderUpdateContent(_:_:_:))

Feeds content bytes into the encoder.

[`CMSEncoderCreate(_:)`](/documentation/Security/CMSEncoderCreate(_:))

Creates a CMSEncoder reference.

[`CMSDecoderSetDetachedContent(_:_:)`](/documentation/Security/CMSDecoderSetDetachedContent(_:_:))

Specifies the message’s detached content, if any.



---

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)