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 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

I've been playing around with Qt for a few hours now. I found that
I've been playing around with upgrading from an iPhone app to a Universal application,
Playing around with MSVC++ 2005, I noticed that if the same class is defined
I'm interested in playing around with OpenGL in Python. I've used OpenGL in C++
I'm implementing a new iPhone app and am relatively new to Cocoa development overall.
Does anyone have some useful beginner tutorials and code snippets for playing with basic
I'm experimenting with the sensors of the iPhone. At the moment I visualize the
I'd like to start experimenting with Cocoa and programming for Mac OSX. I'm not
I've created a iPhone static library project with two targets like this Project -->
I'm going to do something I never thought I'd do... learn how to program

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.