---
title: clearsSelectionOnViewWillAppear
framework: uikit
role: symbol
role_heading: Instance Property
path: uikit/uicollectionviewcontroller/clearsselectiononviewwillappear
---

# clearsSelectionOnViewWillAppear

A Boolean value indicating if the controller clears the selection when the collection view appears.

## Declaration

```swift
var clearsSelectionOnViewWillAppear: Bool { get set }
```

## Discussion

Discussion The default value of this property is true. When true, the collection view controller clears the collection view’s current selection when it receives a viewWillAppear(_:) message. Setting this property to false preserves the selection.

## See Also

### Configuring the collection view behavior

- [installsStandardGestureForInteractiveMovement](uikit/uicollectionviewcontroller/installsstandardgestureforinteractivemovement.md)
