• 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
Re: Displaying multiple errors in NSOpenPanel beginSheetModalForWindow:completionHandler:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying multiple errors in NSOpenPanel beginSheetModalForWindow:completionHandler:


  • Subject: Re: Displaying multiple errors in NSOpenPanel beginSheetModalForWindow:completionHandler:
  • From: Kyle Sluder <email@hidden>
  • Date: Tue, 24 Feb 2015 11:18:04 -0600

On Tue, Feb 24, 2015, at 03:09 AM, Steve Mills wrote:
> Just doing it that way puts up lots of overlapping alert sheets without
> waiting for the user to respond. While that certainly would keep the user
> on their toes, it's not at all right. I've tried using a semaphore to
> wait for the alert (couldn't process user input), running the alert in a
> dispatch_sync block (that just blocked), and a bunch of other stuff.
>
> Ideas?

This sounds like the kind of thing -[NSDocument
performActivityWithSynchronousWaiting:usingBlock:] was designed for,
though it's a rather tricky API. Here's my stab at it:

- (IBAction)showMyOpenPanel:(id)sender {
  NSOpenPanel *op = /* ... */
  [self performActivityWithSynchronousWaiting:YES usingBlock:^{
    [op beginSheetModalForWindow:self.window completionHandler:^{
      __block BOOL didSuppress = NO;
      for (NSURL *url in op.selectedURLs) {
        if ( ProcessURL(url) == kSomethingBadHappened ) {
          [self performActivityWithSynchronousWaiting:NO usingBlock:{
            if (didSuppress)
              return;
            else {
              [self continueAsynchronousActivityUsingBlock:^{
                NSAlert *alert = /* ... */
                [alert beginSheetModalForWindow:self.window
                completionHandler:^{
                  if (alert.suppressionButton.state == NSOnState)
                    didSuppress = YES;
                }];
              }];
            }
          }];
        } // end kSomethingBadHappened
      }
    }]; // end beginSheetModalForWindow
  }]; // end performActivityWithSynchronousWaiting
}


--Kyle Sluder
_______________________________________________

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: Displaying multiple errors in NSOpenPanel beginSheetModalForWindow:completionHandler:
      • From: Steve Mills <email@hidden>
References: 
 >Displaying multiple errors in NSOpenPanel beginSheetModalForWindow:completionHandler: (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: Convert CGFloat to NSNumber
  • Next by Date: Re: Convert CGFloat to NSNumber
  • Previous by thread: Re: Displaying multiple errors in NSOpenPanel beginSheetModalForWindow:completionHandler:
  • Next by thread: Re: Displaying multiple errors in NSOpenPanel beginSheetModalForWindow:completionHandler:
  • Index(es):
    • Date
    • Thread