---
title: "statusItem(withLength:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsstatusbar/statusitem(withlength:)"
---

# statusItem(withLength:)

Returns a newly created status item that has been allotted a specified space within the status bar.

## Declaration

```swift
func statusItem(withLength length: CGFloat) -> NSStatusItem
```

## Parameters

- `length`: A constant that specifies whether the status item is of fixed width, or variable width. The valid constants are described in doc://com.apple.appkit/documentation/AppKit/status-bar-item-length.

## Return Value

Return Value An NSStatusItem object.

## Discussion

Discussion The receiver does not retain a reference to the status item, so you need to retain it. Otherwise, the object is removed from the status bar when it is deallocated.

## See Also

### Managing Status items

- [removeStatusItem(_:)](appkit/nsstatusbar/removestatusitem(_:).md)
