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

# addWindowsItem(_:title:filename:)

Adds an item to the Window menu for a given window.

```
func addWindowsItem(_ win: NSWindow, title string: String, filename isFilename: Bool)
```

## Parameters

`win`

The window being added to the menu. If this window object already exists in the Window menu, this method has no effect.

`string`

The string to display for the window’s menu item. How the string is interpreted is dependent on the value in the `isFilename` parameter.

`isFilename`

If <doc://com.apple.documentation/documentation/Swift/false>, `aString` appears literally in the menu; otherwise, `aString` is assumed to be a converted pathname with the name of the file preceding the path (the way the `NSWindow` method [`setTitleWithRepresentedFilename(_:)`](/documentation/AppKit/NSWindow/setTitleWithRepresentedFilename(_:)) shows a title)

## Discussion

You rarely need to invoke this method directly because Cocoa places an item in the Window menu automatically whenever you set the title of an `NSWindow` object.

## See Also

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

The string that appears in the title bar of the window or the path to the represented file.



---

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)