---
title: "object_setIvar(_:_:_:)"
framework: objectivec
role: symbol
role_heading: Function
path: "objectivec/object_setivar(_:_:_:)"
---

# object_setIvar(_:_:_:)

Sets the value of an instance variable in an object.

## Declaration

```swift
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

Discussion object_setIvar(_:_:_:) is faster than object_setInstanceVariable if the Ivar for the instance variable is already known.

## See Also

### Working with Instances

- [object_getIndexedIvars(_:)](objectivec/object_getindexedivars(_:).md)
- [object_getIvar(_:_:)](objectivec/object_getivar(_:_:).md)
- [object_getClassName(_:)](objectivec/object_getclassname(_:).md)
- [object_getClass(_:)](objectivec/object_getclass(_:).md)
- [object_setClass(_:_:)](objectivec/object_setclass(_:_:).md)
