Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to wrap an NSAlert so the caller can call one function and get the NSAlert return value (i.e. modal)



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.