I prefer to use the .tag property and set a constant for them.

On Aug 5, 2009, at 1:16 PM, Chase Meadors wrote:

In your delegate, method, do this:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex {

        if ([[alertView title] isEqualToString:@"Some Title"]) {
                
                ...
                return;

        } if ([[alertView title] isEqualToString:@"Some Other Title"]) {

                ...
                return;

        }

}

Feel free to judge based on any other property as well, although title is the simplest and shortest.

On Aug 5, 2009, at 1:08 PM, Agha Khan wrote:

Hi:
I need 2 alerts in my class
Code taken from (the iPhone Developer's Cookbook) and works fine with if you have only one alert. When user presses Ok/Cancel button it (void)alertView:(UIAlertView *)alertView activates function.




- (void) presentSheet
{
        UIAlertView *alert = [[UIAlertView alloc]
                                                  initWithTitle: @"Enter 
Information"
                                                  message:@"Specify the Name and 
URL"
                                                  delegate:self
                                                  cancelButtonTitle:@"Cancel"
                                                  otherButtonTitles:@"OK", nil];
        
        [alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex
{
        printf("User Pressed Button %d\n", buttonIndex + 1);
printf("Text Field 1: %s\n", [[[alertView textFieldAtIndex:0] text] cStringUsingEncoding:1]); printf("Text Field 2: %s\n", [[[alertView textFieldAtIndex:1] text] cStringUsingEncoding:1]);
        [alertView release];
}

Now I have another alert in same file.

- (void) presentSheet2
{
        UIAlertView *alert = [[UIAlertView alloc]
                                                  initWithTitle: @"need 
Information"
                                                  message:@"Have you heard from 
Apple"
                                                  delegate:self
                                                  cancelButtonTitle:@"No"
                                                  otherButtonTitles:@"Yes", 
nil];
        
        [alert show];
}


How can we distinguish which alert we are talking about?
Thanks in advance.

Agha

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/c.ed.mead %40gmail.com

This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net

This email sent to [email protected]

Alex Kac - President and Founder
Web Information Solutions, Inc.

"Forgiveness is not an occasional act: it is a permanent attitude."
-- Dr. Martin Luther King




_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to