---
title: didChangeSelectionNotification
framework: appkit
role: symbol
role_heading: Type Property
path: appkit/nstextview/didchangeselectionnotification
---

# didChangeSelectionNotification

Posted when the selected range of characters changes.

## Declaration

```swift
class let didChangeSelectionNotification: NSNotification.Name
```

## Discussion

Discussion NSTextView posts this notification whenever setSelectedRange(_:affinity:stillSelecting:) is invoked, either directly or through the many methods (mouseDown(with:), selectAll(_:), and so on) that invoke it indirectly. When the user is selecting text, this notification is posted only once, at the end of the selection operation. The text view’s delegate receives a textViewDidChangeSelection(_:) message when this notification is posted. The notification object is the notifying text view. The userInfo dictionary contains the following information:  |   |  To observe this notification using Swift concurrency, use NSTextView.DidChangeSelectionMessage.

## See Also

### Notifications

- [willChangeNotifyingTextViewNotification](appkit/nstextview/willchangenotifyingtextviewnotification.md)
- [didChangeTypingAttributesNotification](appkit/nstextview/didchangetypingattributesnotification.md)
- [didSwitchToNSLayoutManagerNotification](appkit/nstextview/didswitchtonslayoutmanagernotification.md)
- [willSwitchToNSLayoutManagerNotification](appkit/nstextview/willswitchtonslayoutmanagernotification.md)
