---
title: "addWindowsItem(_:title:filename:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsapplication/addwindowsitem(_:title:filename:)"
---

# addWindowsItem(_:title:filename:)

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

## Declaration

```swift
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 doc://com.apple.appkit/documentation/AppKit/NSWindow/setTitleWithRepresentedFilename(_:) shows a title)

## Discussion

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

### Related Documentation

- [title](appkit/nswindow/title.md)

### Managing the Window Menu

- [windowsMenu](appkit/nsapplication/windowsmenu.md)
- [changeWindowsItem(_:title:filename:)](appkit/nsapplication/changewindowsitem(_:title:filename:).md)
- [removeWindowsItem(_:)](appkit/nsapplication/removewindowsitem(_:).md)
- [updateWindowsItem(_:)](appkit/nsapplication/updatewindowsitem(_:).md)
