# `GSLayer.selection`

*Instance Property*

The selected elements in selection order.

## Declaration

```swift
var selection: NSOrderedSet { get set }
```

```objc
@property (nonatomic, strong) NSOrderedSet<NSObject<GSSelectableElementProtocol> *> * selection;
```

[See also `selection` in the Python API](https://docu.glyphsapp.com/#GSLayer.selection)

```python
pyobjc_instanceMethods.selection() -> NSOrderedSet<NSObject<GSSelectableElementProtocol> *>
pyobjc_instanceMethods.setSelection_(selection: NSOrderedSet<NSObject<GSSelectableElementProtocol> *>)
```

## Discussion

Selecting nodes does not add their path to the selection.

## See Also

### Selection

- [`GSLayer countOfSelection`](/Core/GlyphsCore/GSLayer/countOfSelection) — The number of selected elements.
- [`GSLayer setSelectionUndo:`](/Core/GlyphsCore/GSLayer/setSelectionUndo:) — Replaces the selection and registers the previous selection for undo.
- [`GSLayer addSelection:`](/Core/GlyphsCore/GSLayer/addSelection:) — Adds an element to the selection if it is not already selected.
- [`GSLayer addObjectsFromArrayToSelection:`](/Core/GlyphsCore/GSLayer/addObjectsFromArrayToSelection:) — Adds elements to the selection, preserving their order.
- [`GSLayer replaceSelection:`](/Core/GlyphsCore/GSLayer/replaceSelection:) — Replaces the selection without registering undo.
- [`GSLayer removeObjectFromSelectionAtIndex:`](/Core/GlyphsCore/GSLayer/removeObjectFromSelectionAtIndex:) — Removes the selected element at an index.
- [`GSLayer removeObjectFromSelection:`](/Core/GlyphsCore/GSLayer/removeObjectFromSelection:) — Removes an element from the selection.
- [`GSLayer removeObjectsFromSelection:`](/Core/GlyphsCore/GSLayer/removeObjectsFromSelection:) — Removes elements from the selection.
- [`GSLayer clearSelection`](/Core/GlyphsCore/GSLayer/clearSelection) — Clears the selection without registering undo.
- [`GSLayer clearSelectionUndo`](/Core/GlyphsCore/GSLayer/clearSelectionUndo) — Clears the selection and registers the previous selection for undo.
- [`GSLayer selectionContainsObject:`](/Core/GlyphsCore/GSLayer/selectionContainsObject:) — Whether an element is selected.

