• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
how to wrap an NSAlert so the caller can call one function and get the NSAlert return value (i.e. modal)
[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)


  • 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


  • Follow-Ups:
    • Re: how to wrap an NSAlert so the caller can call one function and get the NSAlert return value (i.e. modal)
      • From: Ken Thomases <email@hidden>
    • Re: how to wrap an NSAlert so the caller can call one function and get the NSAlert return value (i.e. modal)
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: NSURL urlWithString return nil
  • Next by Date: Re: how to wrap an NSAlert so the caller can call one function and get the NSAlert return value (i.e. modal)
  • Previous by thread: Re: adding a custom view to NSPrintPanel
  • Next by thread: Re: how to wrap an NSAlert so the caller can call one function and get the NSAlert return value (i.e. modal)
  • Index(es):
    • Date
    • Thread