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

# image(forSegment:)

Returns the image associated with the specified segment.

## Declaration

```swift
func image(forSegment segment: Int) -> NSImage?
```

## Parameters

- `segment`: The index of the segment whose image 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 image associated with the segment; otherwise, nil.

## See Also

### Configuring a segment image

- [setImage(_:forSegment:)](appkit/nssegmentedcontrol/setimage(_:forsegment:).md)
- [setImageScaling(_:forSegment:)](appkit/nssegmentedcontrol/setimagescaling(_:forsegment:).md)
- [imageScaling(forSegment:)](appkit/nssegmentedcontrol/imagescaling(forsegment:).md)
