<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMutableAttributedString/fixAttributes(in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMutableAttributedString(im)fixAttributesInRange:"
  },
  "title" : "fixAttributes(in:)"
}
-->

# fixAttributes(in:)

Cleans up font, paragraph style, and attachment attributes within the given range.

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

## Parameters

`range`

The character range within which to fix attributes. Raises an [`rangeException`](/documentation/Foundation/NSExceptionName/rangeException) if any part of `range` lies beyond the end of the receiver’s characters.

## Discussion

Removes attachment attributes assigned to characters other than <doc://com.apple.documentation/documentation/AppKit/NSTextAttachment/character>, assigns default fonts to characters with illegal fonts for their scripts and otherwise corrects font attribute assignments, and assigns the first paragraph style attribute value in each paragraph to all characters of the paragraph.

This method extends the range as needed to cover the last paragraph partially contained.

Raises an [`rangeException`](/documentation/Foundation/NSExceptionName/rangeException) if any part of aRange lies beyond the end of the receiver’s characters.

`NSTextStorage` subclasses that return <doc://com.apple.documentation/documentation/Swift/true> from the <doc://com.apple.documentation/documentation/AppKit/NSTextStorage/fixesAttributesLazily> method should avoid directly calling [`fixAttributes(in:)`](/documentation/Foundation/NSMutableAttributedString/fixAttributes(in:)) or else bracket such calls with [`beginEditing()`](/documentation/Foundation/NSMutableAttributedString/beginEditing()) and [`endEditing()`](/documentation/Foundation/NSMutableAttributedString/endEditing()) messages.

---

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)