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

# isEqual(to:)

Returns a Boolean value that indicates whether the attributed string is equal to the specified string.

```
func isEqual(to other: NSAttributedString) -> Bool
```

## Parameters

`other`

The attributed string with which to compare the receiver.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the text and attributes in the current string and `otherString` are the same, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

This method performs a character-by-character comparison of the string and its attributes. The character and its attributes must be the same in both strings for the method to return <doc://com.apple.documentation/documentation/Swift/true>. In attributed strings with many attributes, such a comparison is unlikely to yield an exact match <doc://com.apple.documentation/documentation/Swift/true>.

---

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)