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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:43:03+00:00 2026-05-16T22:43:03+00:00

I am playing around with xCode and was trying to create a small app

  • 0

I am playing around with xCode and was trying to create a small app that comprises of a table view (built using an array) comprising the names of various individuals. The user would be able to click on one of the rows in the table view and would be shown a UIAlert with an option to call the person or cancel.

If they click on cancel, the UIalert dismisses. If they click on the Call button, I want to launch the Phone application and dial their number.

Here’s what I have in terms of code thus far:

//Generate the UIAlert when the user clicks on a row
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexpath
{
    NSUInteger row = [indexpath row];
    NSString *rowValue = [listData objectAtIndex:row];

    NSString *message = [[NSString alloc] initWithFormat:@"Contact %@", rowValue];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Call this Office"
                                                    message:message
                                                    delegate:self
                                                    cancelButtonTitle:@"Cancel"
                                          otherButtonTitles:@"Call",nil];   


    [alert show];
    [message release];
    [alert release];
}

//Detect which of the UIAlert buttons was clicked and dial a different number
//based on the index of the original row that was selected
- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex 
{

    switch (row) 
    {
        case 1:         
            if (buttonIndex != [alert cancelButtonIndex]) 
            {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://123456789"]];
            }
            break;

        case 2:         
            if (buttonIndex != [alert cancelButtonIndex]) 
            {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://987654321"]];
            }
            break;

        default:
            break;
    }


}

Here’s my question – I know that my switch statement above won’t work – That method has no idea what “row” is. So, how exactly do I pass in/access the index of the row that the user tapped for use with my switch statement?

  • 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-16T22:43:03+00:00Added an answer on May 16, 2026 at 10:43 pm

    When you create the UIAlertView right before you say [alert show] set its tag

    alert.tag = [indexPath row];
    

    now in your switch(row) statement do

    switch(alert.tag)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After playing around with links in Rails for a view hours i've managed to
I have been playing around with the concept of 'module' that some mvc frameworks
I was playing around the new swiftmailer 4.0.4 using my zend studio embbeded apache
Whilst playing around in an open source project, my attempt to ToString a DateTime
Im playing around with the soundcloud api , in its instructions it says to
I've been playing around with Mongo for about a week now and I still
I've been playing around with faceted search and the available display styles and wanted
I'm playing around with an idea(never played with TypeDescriptors before), and managed to get
I have a Mac with Leopard installed (not Snow Leopard). I'm trying to start
I know this must be asked a millions times and can't be easy to

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.