>
> The suggested alternative is NSAlertFirstButtonReturn, etc., which have
> values, which very much unlike the actual returned values.
Those values worked for me found by trial an error because the documentation
and headers made no sense at all. I was working in swift and found
this code to work.
var alert = NSAlert()
alert.addButtonWithTitle(NSLocalizedString("SAVE", comment: "Save"))
alert.addButtonWithTitle(NSLocalizedString("CANCEL", comment: "Cancel"))
alert.addButtonWithTitle(NSLocalizedString("DONT_SAVE", comment: "Don't
Save"))
alert.messageText = NSLocalizedString("UNSAVED_TITLE", comment: "Unsaved
Changes")
alert.informativeText = NSLocalizedString("UNSAVED_DESC", comment: "Unsaved
Changes")
alert.beginSheetModalForWindow(window) {
(response: NSModalResponse) -> Void in
switch response {
case NSAlertFirstButtonReturn: // Save
self.save(nil)
case NSAlertSecondButtonReturn: // Cancel
// Close/terminate cancelled
return
default:
// Don't bother saving
break
}
window.documentEdited = false
window.close()
}
NSAlertFirstButtonReturn was the value returned when the first button
added to the NSAlert was pressed, etc.
I don't understand it. I accept that it works (for now, anyway)
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]