<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSApplication/window(withWindowNumber:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSApplication(im)windowWithWindowNumber:"
  },
  "title" : "window(withWindowNumber:)"
}
-->

# window(withWindowNumber:)

Returns the window corresponding to the specified window number.

```
func window(withWindowNumber windowNum: Int) -> NSWindow?
```

## Parameters

`windowNum`

The unique window number associated with the desired [`NSWindow`](/documentation/AppKit/NSWindow) object.

## Return Value

The desired window object or `nil` if the window could not be found.

## Discussion

[`window(withWindowNumber:)`](/documentation/AppKit/NSApplication/window(withWindowNumber:)) may return `nil` for window numbers found using [`windowNumbers(options:)`](/documentation/AppKit/NSWindow/windowNumbers(options:)) if there is no corresponding window object owned by your app—for example, the menu bar.

---

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)