Skip to content

Instantly share code, notes, and snippets.

@keitaoouchi
Created January 6, 2016 08:47
Show Gist options
  • Save keitaoouchi/7fa4a5a8d9010541f655 to your computer and use it in GitHub Desktop.
Save keitaoouchi/7fa4a5a8d9010541f655 to your computer and use it in GitHub Desktop.
Observing notifications from iTunes on OSX
import Cocoa
let nc = NSDistributedNotificationCenter.defaultCenter()
nc.addObserverForName(nil, object: nil, queue: nil) { notification in
if let info = notification.userInfo where notification.name == "com.apple.iTunes.playerInfo" {
print(info)
}
}
NSRunLoop.mainRunLoop().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment