Skip to content

Instantly share code, notes, and snippets.

@d-srd
Created March 12, 2019 10:15
Show Gist options
  • Save d-srd/01871c59f4ee761a4de1e18909373c8a to your computer and use it in GitHub Desktop.
Save d-srd/01871c59f4ee761a4de1e18909373c8a to your computer and use it in GitHub Desktop.
class StatusItemController {
let statusItem: NSStatusItem
var title: String {
get {
return statusItem.button?.title ?? ""
}
set {
statusItem.button?.title = newValue
}
}
init(statusItem: NSStatusItem) {
self.statusItem = statusItem
}
convenience init(title: String) {
let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
self.init(statusItem: item)
statusItem.button?.title = title
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment