<!--
{
  "availability" : [
    "macOS: 10.0.0 - 15.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindow/init(windowRef:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindow(im)initWithWindowRef:"
  },
  "title" : "init(windowRef:)"
}
-->

# init(windowRef:)

Returns a Cocoa window created from a Carbon window.

```
convenience init?(windowRef: UnsafeMutableRawPointer)
```

## Parameters

`windowRef`

The Carbon `WindowRef` object to use to create the Cocoa window.

## Return Value

A Cocoa window created from `windowRef`.

## Discussion

For more information on Carbon-Cocoa integration, see Using a Carbon User Interface in a Cocoa Application in Carbon-Cocoa Integration Guide.

### Special Considerations

For historical reasons, contrary to normal memory management policy `initWithWindowRef:` does *not* retain `windowRef`. It is therefore recommended that you make sure you retain `windowRef` before calling this method. If `windowRef` is still valid when the Cocoa window is deallocated, the Cocoa window will release it.

## See Also

[`NSWindow`](/documentation/AppKit/NSWindow)

A window that an app displays on the screen.



---

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)