Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 211139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:04:07+00:00 2026-05-11T18:04:07+00:00

I’m new to the iPhone and I would like to be able to use

  • 0

I’m new to the iPhone and I would like to be able to use UIAlertView in a manner similar to the Windows MessageBox() or the MessageDlg() in Delphi.

For example, I have a method that needs to ask the user for confirmation on something, and proceed based on their response.

E.g. (pseudocode):

-(void)doSomething
{
  [doStep1];
  [doStep2];
  var myValue = [getDefaultValue];

  if (myValue = nil)
  {
    if [promptUser(@"No value in setting. Use the default value?")] //UIAlertView here?
    {
       myValue = @"defaultValue";
    }
    else
      return;  // bug out of the routine 'cause we have no value.
  }

  [doStep3 withValue:myValue];

}

Or, put put it another way- is there a way of using UIAlertView to ask the user a question within a routine as a way of controlling the logic flow of that routine?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:04:07+00:00Added an answer on May 11, 2026 at 6:04 pm

    I have no idea what MessageDlg() is, but you can certainly subclass UIAlertView and handle the dialog response, based on which button is pressed, e.g.:

    Set up the UIAlertView subclass header:

    //
    //  ARReachabilityAlertView.h
    //
    
    #import <UIKit/UIKit.h>
    
    @interface ARReachabilityAlertView : UIAlertView <UIAlertViewDelegate> {
    }
    
    @end
    

    Set up the UIAlertView subclass implementation:

    //
    //  ARReachabilityAlertView.m
    //
    
    #import "ARReachabilityAlertView.h"
    
    @implementation ARReachabilityAlertView
    
    - (id)initWithFrame:(CGRect)frame {
      if (self = [super initWithFrame:frame]) {
        [self setTitle:@"Error"];
        [self setMessage:@"This application won't run without a network connection. Do you want to quit?"];
        [self addButtonWithTitle:@"Quit"];
        [self addButtonWithTitle:@"Continue"];
        [self setDelegate:self];
      }
      return self;
    }
    
    - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
      if (buttonIndex == 0)
        exit(0); // quit application if "Quit" is pressed; otherwise, do nothing
    }
    
    - (void) drawRect:(CGRect)rect {
      [super drawRect:rect];
    }
    
    - (void) dealloc {
      [super dealloc];
    }
    
    @end
    

    Note the alertView:clickedButtonAtIndex: delegate method. This handles the conditionals you use to decide how the application proceeds. You can send an NSNotification from here, or call a method in the application delegate, whatever you want.

    In my example, this UIAlertView is instantiated if there is no network connection, and the application is closed if the user clicks “Quit” in the alert view. Otherwise, if the user clicks “Continue” the application keeps running as usual.

    Note that the implementation of the subclass requires the drawRect: method be called. I’m not sure if this is a bug or not, since I’d expect the drawRect: method to be called in the super-class; I filed a bug report with Apple on this one, but I haven’t heard anything. Comment it out if you want to see what the effect will be — it’s kind of interesting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to count the length of a string with PHP. The string
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.