---
title: "label(forSegment:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nssegmentedcontrol/label(forsegment:)"
---

# label(forSegment:)

Returns the label of the specified segment.

## Declaration

```swift
func label(forSegment segment: Int) -> String?
```

## Parameters

- `segment`: The index of the segment whose label you want to get. This method raises an exception (doc://com.apple.documentation/documentation/Foundation/NSExceptionName/rangeException) if the index is out of bounds.

## Return Value

Return Value The label of the segment. The returned string contains the entire text of the label, even if that text is normally truncated during drawing.

## See Also

### Configuring the segment text

- [setLabel(_:forSegment:)](appkit/nssegmentedcontrol/setlabel(_:forsegment:).md)
- [setAlignment(_:forSegment:)](appkit/nssegmentedcontrol/setalignment(_:forsegment:).md)
- [alignment(forSegment:)](appkit/nssegmentedcontrol/alignment(forsegment:).md)
