<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMutableAttributedString/fixAttachmentAttribute(in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMutableAttributedString(im)fixAttachmentAttributeInRange:"
  },
  "title" : "fixAttachmentAttribute(in:)"
}
-->

# fixAttachmentAttribute(in:)

Cleans up attachment attributes in the specified range and removes all attachment attributes assigned to characters except the designated attachment character.

```
func fixAttachmentAttribute(in range: NSRange)
```

## Parameters

`range`

The range of characters.

## Discussion

The method preserves the attachment attribute on the <doc://com.apple.documentation/documentation/AppKit/NSTextAttachment/character> special character. The method raises a [`rangeException`](/documentation/Foundation/NSExceptionName/rangeException) if any part of `range` lies beyond the end of the string’s characters.

---

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)