how to wrap an NSAlert so the caller can call one function and get the NSAlert return value (i.e. modal)
how to wrap an NSAlert so the caller can call one function and get the NSAlert return value (i.e. modal)
- Subject: how to wrap an NSAlert so the caller can call one function and get the NSAlert return value (i.e. modal)
- From: Rua Haszard Morris <email@hidden>
- Date: Tue, 13 May 2008 12:18:48 +1200
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.
Thanks
Rua HM.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden