Thanks to DarkDust for pointing me in the right direction. I would never look for “helper looks” in NSAlerts (I didn’t have the right conditions to fool Google or SO to give me a product!). I also forgot to mention that I use Swift, so I quickly typed in a quick translation:
func getString(title: String, question: String, defaultValue: String) -> String {
let msg = NSAlert()
msg.addButtonWithTitle("OK")
msg.addButtonWithTitle("Cancel")
msg.messageText = title
msg.informativeText = question
let txt = NSTextField(frame: NSRect(x: 0, y: 0, width: 200, height: 24))
txt.stringValue = defaultValue
msg.accessoryView = txt
let response: NSModalResponse = msg.runModal()
if (response == NSAlertFirstButtonReturn) {
return txt.stringValue
} else {
return ""
}
}
source
share