---
title: setObject
framework: driverkit
role: symbol
role_heading: Instance Method
path: driverkit/osset/setobject
---

# setObject

Adds an object to the OSSet if it is not already present.

## Declaration

```occ
bool setObject(const OSMetaClassBase *anObject);
```

## Parameters

- `anObject`: The OSMetaClassBase-derived object to be added to the set.

## Return Value

Return Value true if anObject was successfully added to the set, false otherwise (including if it was already in the set).

## Discussion

Discussion The set adds storage to accomodate the new object, if necessary. If successfully added, the object is retained. A false return value can mean either that anObject is already present in the set, or that a memory allocation failure occurred. If you need to know whether the object is already present, use containsObject.
