Is there a way to wrap up an NSAlert, the beginSheetModalForWindow
call, and the alertDidEnd implementation, such that a caller can just
call one function which blocks until the alert is dismissed?
i.e. something like
if ([SynchronousAlert showAlertWithMessageText:@"Do you want to delete
etc" defaultButton:@"Delete" alternateButton:@"Cancel"] ==
NSAlertFirstButtonReturn)
// delete the thing or whatever
I'm starting to see that this is probably bad cocoa style, but at the
same time I find it very inconvenient to have to break up logic so the
code handling the return value is in a different place from the code
that displays the alert - is this really necessary?
For example, let's say you've already implemented some feature, and
later realise that there is a need for a confirmation alert part-way
through the process - you now need to split the post-confirm logic out
to the alertDidEnd - right? Which could be a real hassle?
I've done some web & mailing list searching but haven't found any good
alternatives. Any tips would be greatly appreciated.