---
title: createContext()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nsprintoperation/createcontext()
---

# createContext()

Creates the graphics context object used for drawing during the operation.

## Declaration

```swift
func createContext() -> NSGraphicsContext?
```

## Return Value

Return Value The graphics context object used for drawing. This object is created using the settings from the receiver’s NSPrintInfo object.

## Discussion

Discussion Do not invoke this method directly—it is invoked before any output is generated.

## See Also

### Managing the Drawing Context

- [context](appkit/nsprintoperation/context.md)
- [destroyContext()](appkit/nsprintoperation/destroycontext().md)
