---
title: "fixAttributes(in:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmutableattributedstring/fixattributes(in:)"
---

# fixAttributes(in:)

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

## Declaration

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

## Parameters

- `range`: The character range within which to fix attributes. Raises an doc://com.apple.foundation/documentation/Foundation/NSExceptionName/rangeException if any part of range lies beyond the end of the receiver’s characters.

## Discussion

Discussion Removes attachment attributes assigned to characters other than 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 if any part of aRange lies beyond the end of the receiver’s characters. NSTextStorage subclasses that return true from the fixesAttributesLazily method should avoid directly calling fixAttributes(in:) or else bracket such calls with beginEditing() and endEditing() messages.

## See Also

### Fixing Attributes After Changes

- [fixAttachmentAttribute(in:)](foundation/nsmutableattributedstring/fixattachmentattribute(in:).md)
- [fixFontAttribute(in:)](foundation/nsmutableattributedstring/fixfontattribute(in:).md)
- [fixParagraphStyleAttribute(in:)](foundation/nsmutableattributedstring/fixparagraphstyleattribute(in:).md)
