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

  • Home
  • SEARCH
  • 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 6246165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:38:17+00:00 2026-05-24T12:38:17+00:00

Is it possible to program multiple UIAlertViews for one IBAction in Xcode to show

  • 0

Is it possible to program multiple UIAlertViews for one IBAction in Xcode to show at random. For example: I am making an app with multiple questions shown at random, when the submit button is pressed, an alert is shown saying if the answer is correct or not. I want there to be different messages for the alert such as one time it shows one message, then the next time it shows a different message at random. How would I program this?

  • 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-24T12:38:18+00:00Added an answer on May 24, 2026 at 12:38 pm

    In your .h:

    @interface MyViewController : UIViewController { 
        NSArray *messages;
    }
    
    @property (nonatomic, retain) NSArray *messages;
    

    In your .m

    @implementation MyViewController
    @synthesize messages;
    
    - (dealloc) {
        [messages release];
    }
    
    - (void)viewDidLoad {
        messages = [[NSArray alloc] initWithObjects:@"Funny Message", @"Even Funnier Message", @"Hilarious message", @"ROFL", @"OK this is getting boring...", nil];
    }
    

    When you need an alert:

    NSUInteger messageCount = [messages count];
    int randomMessageIndex = arc4random() % messageCount;
    
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:[messages objectAtIndex:randomMessageIndex] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few questions related: 1) Is possible to make my program change
Basically, is it possible to identify if some-one hooks up my program to SQL
My program requires multiple random recursions, and I have to manually let the script
Possible Duplicate: How can I convert my java program to an .exe file ?
Is it possible to use a C++ .lib file from within a C# program?
I'm wondering if it is possible to add methods in main program to an
I have a string with possible command line arguments (using an Read-Eval-Print-Loop program) and
How to decrease the number of possible cache misses when designing a C++ program?
How can I call a C++ function from a C program, is it possible?,
Is it possible to have multiple sockets, which can either by TCP or UDP

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.