---
title: CFRetain
framework: corefoundation
role: symbol
role_heading: Function
path: corefoundation/cfretain
---

# CFRetain

Retains a Core Foundation object.

## Declaration

```occ
extern CFTypeRefCFRetain(CFTypeRef cf);
```

## Parameters

- `cf`: The CFType object to retain. This value must not be NULL

## Return Value

Return Value The input value, cf.

## Discussion

Discussion You should retain a Core Foundation object when you receive it from elsewhere (that is, you did not create or copy it) and you want it to persist. If you retain a Core Foundation object you are responsible for releasing it (see Memory Management Programming Guide for Core Foundation). Special Considerations If cf is NULL, this will cause a runtime error and your application will crash.

## See Also

### Memory Management

- [CFGetAllocator(_:)](corefoundation/cfgetallocator(_:).md)
- [CFGetRetainCount(_:)](corefoundation/cfgetretaincount(_:).md)
- [CFMakeCollectable](corefoundation/cfmakecollectable.md)
- [CFRelease](corefoundation/cfrelease.md)
