<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObjectProtocol/isEqual(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:objc(pl)NSObject(im)isEqual:"
  },
  "title" : "isEqual(_:)"
}
-->

# isEqual(_:)

Returns a Boolean value that indicates whether the receiver and a given object are equal.

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

## Parameters

`object`

The object to be compared to the receiver. May be `nil`, in which case this method returns [`NO`](/documentation/ObjectiveC/NO).

## Return Value

[`YES`](/documentation/ObjectiveC/YES) if the receiver and `anObject` are equal, otherwise [`NO`](/documentation/ObjectiveC/NO).

## Discussion

This method defines what it means for instances to be equal. For example, a container object might define two containers as equal if their corresponding objects all respond [`YES`](/documentation/ObjectiveC/YES) to an [`isEqual(_:)`](/documentation/ObjectiveC/NSObjectProtocol/isEqual(_:)) request. See the <doc://com.apple.documentation/documentation/Foundation/NSData>, <doc://com.apple.documentation/documentation/Foundation/NSDictionary>, <doc://com.apple.documentation/documentation/Foundation/NSArray>, and <doc://com.apple.documentation/documentation/Foundation/NSString> class specifications for examples of the use of this method.

If two objects are equal, they must have the same hash value. This last point is particularly important if you define [`isEqual(_:)`](/documentation/ObjectiveC/NSObjectProtocol/isEqual(_:)) in a subclass and intend to put instances of that subclass into a collection. Make sure you also define [`hash`](/documentation/ObjectiveC/NSObjectProtocol/hash) in your subclass.

---

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)