---
title: "object_setClass(_:_:)"
framework: objectivec
role: symbol
role_heading: Function
path: "objectivec/object_setclass(_:_:)"
---

# object_setClass(_:_:)

Sets the class of an object.

## Declaration

```swift
func object_setClass(_ obj: Any?, _ cls: AnyClass) -> AnyClass?
```

## Parameters

- `obj`: The object to modify.
- `cls`: A class object.

## Return Value

Return Value The previous value of object’s class, or Nil if object is nil.

## See Also

### Working with Instances

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