<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSGraphicsContext/init(graphicsPort:flipped:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSGraphicsContext(cm)graphicsContextWithGraphicsPort:flipped:"
  },
  "title" : "init(graphicsPort:flipped:)"
}
-->

# init(graphicsPort:flipped:)

Creates a new graphics context from the specified graphics port.

```
init(graphicsPort: UnsafeMutableRawPointer, flipped initialFlippedState: Bool)
```

## Parameters

`graphicsPort`

The graphics port used to create the graphics-context object. Typically `graphicsPort` is a <doc://com.apple.documentation/documentation/CoreGraphics/CGContext> (opaque type) object.

`initialFlippedState`

Specifies the receiver’s initial flipped state. This is the value returned by [`isFlipped`](/documentation/AppKit/NSGraphicsContext/isFlipped) when no view has focus.

## Return Value

The created [`NSGraphicsContext`](/documentation/AppKit/NSGraphicsContext) object, or `nil` if the object could not be created.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)