---
title: withObjects
framework: kernel
role: pseudoSymbol
path: kernel/osset/1808287-withobjects
---

# withObjects

Creates and initializes an OSSet populated with objects provided.

## Declaration

```occ
static OSSet * withObjects( 
 const OSObject *objects[], 
 unsigned int count, 
 unsigned int capacity = 0); 
```

## Parameters

- `objects`: A C array of OSMetaClassBase-derived objects.
- `count`: The number of objects to be placed into the set.
- `capacity`: The initial storage capacity of the new set object. If 0, count is used; otherwise this value must be greater than or equal to count.

## Return Value

Return Value An instance of OSSet containing the objects provided, with a retain count of 1; NULL on failure.

## Overview

Overview objects must be non-NULL, and count must be nonzero. If capacity is nonzero, it must be greater than or equal to count. The new OSSet will grow as needed to accommodate more objects (unlikeCFMutableSet, for which the initial capacity is a hard limit). The objects in objects are retained for storage in the new set, not copied.

## See Also

### Miscellaneous

- [containsObject](kernel/osset/1808031-containsobject.md)
- [copyCollection](kernel/osset/1808046-copycollection.md)
- [ensureCapacity](kernel/osset/1808068-ensurecapacity.md)
- [flushCollection](kernel/osset/1808084-flushcollection.md)
- [free](kernel/osset/1808104-free.md)
- [getAnyObject](kernel/osset/1808128-getanyobject.md)
- [getCapacity](kernel/osset/1808152-getcapacity.md)
- [getCapacityIncrement](kernel/osset/1808173-getcapacityincrement.md)
- [getCount](kernel/osset/1808189-getcount.md)
- [initWithArray](kernel/osset/1808200-initwitharray.md)
- [initWithCapacity](kernel/osset/1808213-initwithcapacity.md)
- [initWithObjects](kernel/osset/1808221-initwithobjects.md)
- [initWithSet](kernel/osset/1808228-initwithset.md)
- [isEqualTo(const OSMetaClassBase *)](kernel/osset/1808235-isequalto.md)
- [isEqualTo(const OSSet *)](kernel/osset/1808239-isequalto.md)
- [member](kernel/osset/1808245-member.md)
- [merge(const OSArray *)](kernel/osset/1808250-merge.md)
- [merge(const OSSet *)](kernel/osset/1808253-merge.md)
- [removeObject](kernel/osset/1808257-removeobject.md)
- [serialize](kernel/osset/1808260-serialize.md)
- [setCapacityIncrement](kernel/osset/1808264-setcapacityincrement.md)
- [setObject](kernel/osset/1808269-setobject.md)
- [withArray](kernel/osset/1808277-witharray.md)
- [withCapacity](kernel/osset/1808282-withcapacity.md)
- [withSet](kernel/osset/1808291-withset.md)
