• 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: Display a UIAlertView after dismissing an action sheet?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Display a UIAlertView after dismissing an action sheet?


  • Subject: Re: Display a UIAlertView after dismissing an action sheet?
  • From: Michael Crawford <email@hidden>
  • Date: Sat, 25 Apr 2015 06:30:27 -0700

On 4/25/15, Mike Abdullah <email@hidden> wrote:
> Apple's APIs here are deliberately asynchronous. You need to make your code
> handle that properly. Don't try to force it to be synchronous.

Some things need to be synchronous though.  If I'm saving a file, I
don't want to do anything else unless the file is saved, or perhaps
the operation is cancelled by the user.

What's your take on the following?  I found the bit with the runloop
at stackoverflow.

+ (NSString*) copyFileName: (NSString*) question
                    withTextPrompt: (NSString*) prompt
{
    ModalAlertDelegate *delegate = [[ModalAlertDelegate alloc] init];

    assert( nil != delegate );
    assert( 1 == [delegate retainCount] );

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle: question
                                                        message: @"Untitled"
                                                       delegate: delegate
                                              cancelButtonTitle: @"Cancel"
                                              otherButtonTitles: @"OK", nil];
    alertView.alertViewStyle = UIAlertViewStylePlainTextInput;

    assert( 1 == [alertView retainCount] );
    assert( 1 == [delegate retainCount] );

    [alertView show];

    while( [alertView isVisible] ){
        NSRunLoop *rl = [NSRunLoop currentRunLoop];
        NSDate *today = [[NSDate alloc] init];

        [rl runUntilDate: today];
        [today release];

    }

    [alertView release];

    NSString *result = [delegate.text copy];

    [delegate release];

    return result;
}

delegate.text is copied from the UIAlertView's text field in the
delegate's buttonClickedAtIndex method.

I don't yet have a way to report that the user cancelled but that will
be simple to add.  This seems to work as far as it goes.

--
Michael David Crawford, Consulting Software Engineer
email@hidden
http://www.warplife.com/mdc/

   Available for Software Development in the Portland, Oregon Metropolitan
Area.
_______________________________________________

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: Display a UIAlertView after dismissing an action sheet?
      • From: Mike Abdullah <email@hidden>
    • Re: Display a UIAlertView after dismissing an action sheet?
      • From: Roland King <email@hidden>
References: 
 >Display a UIAlertView after dismissing an action sheet? (From: Michael Crawford <email@hidden>)
 >Re: Display a UIAlertView after dismissing an action sheet? (From: Roland King <email@hidden>)
 >Re: Display a UIAlertView after dismissing an action sheet? (From: Michael Crawford <email@hidden>)
 >Re: Display a UIAlertView after dismissing an action sheet? (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Display a UIAlertView after dismissing an action sheet?
  • Next by Date: Re: Display a UIAlertView after dismissing an action sheet?
  • Previous by thread: Re: Display a UIAlertView after dismissing an action sheet?
  • Next by thread: Re: Display a UIAlertView after dismissing an action sheet?
  • Index(es):
    • Date
    • Thread