---
title: willSleepNotification
framework: appkit
role: symbol
role_heading: Type Property
path: appkit/nsworkspace/willsleepnotification
---

# willSleepNotification

A notification that the workspace posts before the device goes to sleep.

## Declaration

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

## Discussion

Discussion An observer of this message can delay sleep for up to 30 seconds while handling this notification. The notification object is the shared NSWorkspace instance. The notification doesn’t contain a userInfo dictionary. important: To receive this notification, use notificationCenter to register for it. If you use a different notification center to register, you won’t receive the notification. To observe this notification using Swift concurrency, use NSWorkspace.WillSleepMessage.

## See Also

### Responding to Environment Notifications

- [willLaunchApplicationNotification](appkit/nsworkspace/willlaunchapplicationnotification.md)
- [didLaunchApplicationNotification](appkit/nsworkspace/didlaunchapplicationnotification.md)
- [didTerminateApplicationNotification](appkit/nsworkspace/didterminateapplicationnotification.md)
- [sessionDidBecomeActiveNotification](appkit/nsworkspace/sessiondidbecomeactivenotification.md)
- [sessionDidResignActiveNotification](appkit/nsworkspace/sessiondidresignactivenotification.md)
- [didHideApplicationNotification](appkit/nsworkspace/didhideapplicationnotification.md)
- [didUnhideApplicationNotification](appkit/nsworkspace/didunhideapplicationnotification.md)
- [didActivateApplicationNotification](appkit/nsworkspace/didactivateapplicationnotification.md)
- [didDeactivateApplicationNotification](appkit/nsworkspace/diddeactivateapplicationnotification.md)
- [didRenameVolumeNotification](appkit/nsworkspace/didrenamevolumenotification.md)
- [didMountNotification](appkit/nsworkspace/didmountnotification.md)
- [willUnmountNotification](appkit/nsworkspace/willunmountnotification.md)
- [didUnmountNotification](appkit/nsworkspace/didunmountnotification.md)
- [didChangeFileLabelsNotification](appkit/nsworkspace/didchangefilelabelsnotification.md)
- [activeSpaceDidChangeNotification](appkit/nsworkspace/activespacedidchangenotification.md)
