Category: Swift
Set the badge icon for applications running in the dock on macOS in Swift code as follows:
NSApp.dockTile.badgeLabel = "7";
Clear the badge icon by setting the value to an empty string.
NSApp.dockTile.badgeLabel = "";
Do not set the value in the string to a non-numeric value. Apple Human User Interface guidelines also suggest using badging to supplement notifications, not to denote critical information.