---
title: "setSelected(_:animated:)"
framework: mapkit
role: symbol
role_heading: Instance Method
path: "mapkit/mkannotationview/setselected(_:animated:)"
---

# setSelected(_:animated:)

Sets the selection state of the annotation view.

## Declaration

```swift
func setSelected(_ selected: Bool, animated: Bool)
```

## Parameters

- `selected`: Contains the value doc://com.apple.documentation/documentation/Swift/true if the view displays in a selected state.
- `animated`: Set to doc://com.apple.documentation/documentation/Swift/true if the map view animates the change in selection state.

## Discussion

Discussion Dont call this method directly. An MKMapView object calls this method in response to user interactions with the annotation.

## See Also

### Related Documentation

- [selectAnnotation(_:animated:)](mapkit/mkmapview/selectannotation(_:animated:).md)

### Managing the selection state

- [isSelected](mapkit/mkannotationview/isselected.md)
