Contents

setSelected(_:forSegment:)

Sets the selection state of the specified segment.

Declaration

func setSelected(_ selected: Bool, forSegment segment: Int)

Parameters

  • selected:

    True if you want to select the segment; otherwise, False.

  • segment:

    The index of the segment whose selection state you want to set. This method raises an exception (Rangeexception) if the index is out of bounds.

Discussion

If the control allows only a single selection, this method deselects any other selected segments.

If the trackingMode property of the segment is set to NSSegmentedControl.SwitchTracking.momentary, then attempting to set the selected state of the segment will have no effect.

See Also

Managing the selected segment