Challenge: Beep-Beep!


There isn’t a current solution to this challenge, so here’s my 2 cents.

In the AppDelegate.swift:

func applicationDidFinishLaunching(aNotification: NSNotification) { addWindowController() addResignActiveNotification() }

func applicationWillTerminate(aNotification: NSNotification) {
let notificationCenter = NSNotificationCenter.defaultCenter()

func addResignActiveNotification() {

let notificationCenter = NSNotificationCenter.defaultCenter()
    selector: #selector(applicationInactive),
    name: NSApplicationDidResignActiveNotification,
    object: nil)


func applicationInactive(notification: NSNotification) {


Since AppDelegate is already the Application’s delegate and in standard Cocoa objects a delegate is already registered as on observer for the methods it implements the only thing needed to make the beeping work is to add this function to AppDelegate:

func applicationDidResignActive(notification: NSNotification) {


And there was me feeling all smug.


In Xcode 9.0+, use NSSound.beep()