<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/isEqual(to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime",
      "ObjectiveC"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)isEqualTo:"
  },
  "title" : "isEqual(to:)"
}
-->

# isEqual(to:)

Returns a Boolean value that indicates whether the receiver is equal to another given object.

```
func isEqual(to object: Any?) -> Bool
```

## Parameters

`object`

The object with which to compare the receiver.

## Return Value

[`YES`](/documentation/ObjectiveC/YES) if the receiver is equal to `object`, otherwise [`NO`](/documentation/ObjectiveC/NO). In effect returns [`NO`](/documentation/ObjectiveC/NO) if receiver is `nil`.

## Discussion

During the evaluation of an `NSWhoseSpecifier` object that contains a test whose operator is `NSEqualToComparison`, an [`isEqual(to:)`](/documentation/ObjectiveC/NSObject-swift.class/isEqual(to:)) message may be sent to each potentially specified object, if neither the potentially specified object nor the object being tested against implements a [`scriptingIsEqual(to:)`](/documentation/ObjectiveC/NSObject-swift.class/scriptingIsEqual(to:)) method.

The default implementation for this method provided by `NSObject` returns [`YES`](/documentation/ObjectiveC/YES) if an `isEqualTo:` message sent to the same object would return [`YES`](/documentation/ObjectiveC/YES).

---

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)