---
title: "init(window:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nsgraphicscontext/init(window:)"
---

# init(window:)

Creates a new graphics context for drawing into a window.

## Declaration

```swift
init(window: NSWindow)
```

## Parameters

- `window`: The window object representing the window to use for drawing.

## Return Value

Return Value The created NSGraphicsContext object, or nil if the object could not be created.

## See Also

### Creating a Graphics Context

- [init(attributes:)](appkit/nsgraphicscontext/init(attributes:).md)
- [init(bitmapImageRep:)](appkit/nsgraphicscontext/init(bitmapimagerep:).md)
- [init(cgContext:flipped:)](appkit/nsgraphicscontext/init(cgcontext:flipped:)-9cbad.md)
- [init(graphicsPort:flipped:)](appkit/nsgraphicscontext/init(graphicsport:flipped:).md)
