---
title: "object_getIvar(_:_:)"
framework: objectivec
role: symbol
role_heading: Function
path: "objectivec/object_getivar(_:_:)"
---

# object_getIvar(_:_:)

Reads the value of an instance variable in an object.

## Declaration

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

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

## Discussion

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

## See Also

### Working with Instances

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