---
title: CGContextRetain
framework: coregraphics
role: symbol
role_heading: Function
path: coregraphics/cgcontextretain
---

# CGContextRetain

Increments the retain count of a graphics context.

## Declaration

```occ
extern CGContextRefCGContextRetain(CGContextRef c);
```

## Parameters

- `c`: The graphics context to retain.

## Return Value

Return Value The same graphics context you passed in as the context parameter.

## Discussion

Discussion This function is equivalent to CFRetain, except it does not cause an error if c is NULL.

## See Also

### Retaining and Releasing Graphics Contexts

- [CGContextRelease](coregraphics/cgcontextrelease.md)
