# `GSLayer selectionContainsObject:`

*Instance Method*

Whether an element is selected.

## Declaration

```swift
func selectionContainsObject(_ object: (any GSSelectableElementProtocol)?) -> Bool
```

```objc
- (BOOL) selectionContainsObject:(GSSelectableElement *) object;
```

```python
selectionContainsObject_(object: GSSelectableElement) -> bool
```

## Discussion

Returns `NO` for `nil`.

## See Also

### Selection

- [`GSLayer.selection`](/Core/GlyphsCore/GSLayer/selection) — The selected elements in selection order.
- [`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.

