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 8358245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:44:04+00:00 2026-06-09T10:44:04+00:00

I have code setting up a UIAlertView: -(IBAction)showMessage { //NSInteger *buttonIndex = NULL; UIAlertView

  • 0

I have code setting up a UIAlertView:

-(IBAction)showMessage
{
//NSInteger *buttonIndex = NULL;
UIAlertView *message = [[UIAlertView alloc] initWithTitle:nil 
message:nil 
delegate:nil 
cancelButtonTitle:@"Cancel" 
otherButtonTitles:@"Email",@"SMS",@"Facebook",@"Twitter", nil];
[message show];
}

and code explaining what to do once the user makes a choice:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1){
        [self openMail];
    }
    else if (buttonIndex == 2)
//etc.
}

But what I can’t figure out is how to connect the two. The obvious answer is to add a line to the first piece of code calling alertView: clickedButtonAtIndex on UIAlertView *message, but how do you assign buttonIndex? How do you tell alertView whether the user has chosen Facebook, Email, etc?

  • 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-06-09T10:44:06+00:00Added an answer on June 9, 2026 at 10:44 am

    Add to the header file if you haven’t already:

    @interface YourClass : UIViewController <UIAlertViewDelegate>
    {
    }
    

    …etc

    and in your AlertView code change delegate:nil to delegate:self

    For more information have a look at the Apple Docs:
    http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIAlertViewDelegate_Protocol/UIAlertViewDelegate/UIAlertViewDelegate.html

    From the docs:
    The button indices start at 0. If this is the cancel button index, the alert view is canceling. If -1, the cancel button index is not set.

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

Sidebar

Related Questions

So... is strange, I have the follow code in my Window control for setting
I have this code for setting random values to true in a boolean[][], without
I Have folowing Button code and setting to take user to google for login
I have following code to set the font for setting the telugu font. while
I have generic code for setting up and tearing down NHibernate, which I need
I have the following code for setting up text in a UIButton [self.fullListButton_ setTitle:[NSString
I have some basic jquery code sitting in the header of the header file
I have this code for the settings: Dim settings As XmlWriterSettings = New XmlWriterSettings()
I have the following code in settings.py #EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER
I have this code: int se = (int) settings.GruppoSegreteria; var acc = db.USR_Accounts.Where( p

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.