<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/object_getIvar(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:@F@object_getIvar"
  },
  "title" : "object_getIvar(_:_:)"
}
-->

# object_getIvar(_:_:)

Reads the value of an instance variable in an object.

```
func object_getIvar(_ obj: Any?, _ ivar: Ivar) -> Any?
```

## Parameters

`obj`

The object containing the instance variable whose value you want to read.

`ivar`

The Ivar describing the instance variable whose value you want to read.

## Return Value

The value of the instance variable specified by `ivar`, or `nil` if `object` is `nil`.

## Discussion

[`object_getIvar(_:_:)`](/documentation/ObjectiveC/object_getIvar(_:_:)) is faster than [`object_getInstanceVariable`](/documentation/ObjectiveC/object_getInstanceVariable) if the Ivar for the instance variable is already known.

---

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)