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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:21:16+00:00 2026-05-20T12:21:16+00:00

i am having a weird problem with uialert views. i have several alerts are

  • 0

i am having a weird problem with uialert views.

i have several alerts are member variables in my .h file

UIAlertView *changepwalert;  //change password alert.
UIAlertView *delallalert;  //delete selected transactions.
UIAlertView *logout; //logout alert.
UIAlertView *closingbalancealert; //closing balance alert.
UIAlertView *totalreportalert; //total report alert.
UIAlertView *ordercashalert; //order cash alert.
UIAlertView *unlockingalert; //unlocking alert.
UIAlertView *receivecashalert;

in my .m file i have the following for didDismissWithButtonIndex delegate method.

if(alertView==unlockingalert && buttonIndex==0)
{
    //code
}

else if(alertView==ordercashalert && buttonIndex==0)
{
    //code

}
else if(alertView==receivecashalert && buttonIndex==0)
{
    //code
}
else if (alertView==logout && buttonIndex == 0)
{
    //code
}
else if(alertView==closingbalancealert && buttonIndex==0)
{
       //code
}
else if (alertView==changepwalert && buttonIndex==0)
{
    //code
}
else if(alertView==delallalert && buttonIndex==0)
{
    //code
}   

Here is a sample of how i am initializing the uialertview

ordercashalert = [[UIAlertView alloc] initWithTitle:nil message:@"Enter Password\n\n\n\n\n\n" delegate:self 
                                    cancelButtonTitle:@"Ok" otherButtonTitles:@"Cancel",nil];


logout = [[UIAlertView alloc] initWithTitle:@"Logout" message:@"Are You Sure?" delegate:self cancelButtonTitle:@"YES" otherButtonTitles:@"NO",nil];
[logout show];
[logout release];

when i click the logout button it runs the delegate method but it matches the alert to ordercashalert or receivecashalert.i am not sure why. it should actually match with logout alert. i am at the final stages of delivering the product and all of a sudden i have this bug. can some one help me please.

  • 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-20T12:21:17+00:00Added an answer on May 20, 2026 at 12:21 pm

    I’d suggest you use tag and enumeration trick. First – create enumeration for all possible alerts:

    enum {
        RSChangePasswordAlertTag,
        RSDeleteAlertTag,
        ....
        ReceiveCashAlertTag
    };
    

    Then when creating the alert, just assign appropriate tag to it

    UIAlertView *myAlert = [[[UIAlertView alloc] initWithTitle:....] autorelease];
    [myAlert setTag:RSDeleteAlertTag];
    [myAlert show];
    

    Then in delegate method use switch statement for alertView‘s tag:

    - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSUInteger)buttonIndex {
        switch (alertView.tag) {
            case RSPasswordAlertTag: {
                // Do password alert thing
                break;
            }
            case RSDeleteAlertTag: { 
                // do delete thing
                break;
            }
            .... // here be other cases
        }
    }
    

    This way you’d be comparing only integers instead of pointers and your code will be cleaner with less instance variables.

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

Sidebar

Related Questions

This is a really weird problem that I have been having. When I download
This is a weird problem I have started having recently. My team is developing
I am having a weird problem. I read a text file then I split
I'm having a weird problem, I have the following code in my page.php template
I'm having a weird problem. I have this code $topic contains 海賊_(ONE_PIECE) from URI
I'm having quite a weird problem here. I have just pasted the Yii folder
I am trying to write the manifest file but I am having weird problem
I’m having a weird problem with notifications. I have created an on going notification,
I'm having an extremely weird problem with a PHP script of mine. I'm uploading
I'm new to Ruby, so I'm having some trouble understanding this weird exception problem

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.