<!--
{
  "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_setIvar(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:@F@object_setIvar"
  },
  "title" : "object_setIvar(_:_:_:)"
}
-->

# object_setIvar(_:_:_:)

Sets the value of an instance variable in an object.

```
func object_setIvar(_ obj: Any?, _ ivar: Ivar, _ value: Any?)
```

## Parameters

`obj`

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

`ivar`

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

`value`

The new value for the instance variable.

## Discussion

[`object_setIvar(_:_:_:)`](/documentation/ObjectiveC/object_setIvar(_:_:_:)) is faster than [`object_setInstanceVariable`](/documentation/ObjectiveC/object_setInstanceVariable) 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)