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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:14:17+00:00 2026-05-17T22:14:17+00:00

I have having a very odd issue when utilizing this UIAlertView. When viewing a

  • 0

I have having a very odd issue when utilizing this UIAlertView. When viewing a Physician they have several offices. Upon selecting one you get an alert that offers to call this location or display it on a map. To create the alert and to have data at the ready when the alert is dismissed, I declared 4 NSStrings (although I probably only need 2) in the header file. (alertTitle, alertText, alertNumber, and alertAddress)

When looking at the code, the problem is where the alertAddress is involved. Also keep alertNumber in mind. I had a lot of this code condensed but have expanded it to help myself find the problem!

 -(IBAction)address1ButtonPressed:(id) sender {
        Formatter *pnf = [Formatter alloc];
        alertTitle = [physician objectForKey:ADDRESS1DESC_KEY];
        NSString *a = [physician objectForKey:ADDRESS1A_KEY];
        NSString *b =[physician objectForKey:ADDRESS1CITY_KEY];
        NSString *c =[physician objectForKey:ADDRESS1STATE_KEY];
        NSString *d = [physician objectForKey:ADDRESS1ZIP_KEY];
        NSString *p = [physician objectForKey:PHONE1A_KEY];
        alertAddress = [[NSString stringWithFormat:@"http://maps.google.com/maps?q=%@,+%@,+%@+%@",a,b,c,d] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSLog(@"%@",alertAddress);
        alertText = [NSString stringWithFormat:@"%@\n%@, %@ %@\n%@",a,b,c,d,[pnf stringFromPhoneNumber:p]];
        alertNumber = [p stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
        [pnf release];
        UIAlertView *phoneAlert = [[UIAlertView alloc] initWithTitle:alertTitle message:alertText delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Call",@"View Map",nil];
        [phoneAlert show];

        }

All is well until we reach the point where we handle the alert dismissal. alertNumber seems to come across just fine, I can use it to trigger the phone call and Log it to the console.

alertAddress however is not at all happy about doing the same thing. even trying to Log it to the Console causes a EXC_BAD_ACCESS. alertAddress logs the data correctly before the alert is involved but accessing this data at all when handling the alert button dismissal causes a problem. I have even used the alertNumber it is place and the code functions perfectly.

Why are both exact same NSString variables behaving so differently when used the exact same way?

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 1) {
        NSLog(@"Dialing: %@",alertNumber);
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",alertNumber]]];      
    }
    if (buttonIndex == 2) {
        NSLog(@"Map Selected");
        NSLog(@"alertAddress contains: %@",alertAddress);
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.google.com/maps?q=%@",alertAddress]]];     
    }
}

Here are the related declarations in the header file too…

@interface PhysicianDetailViewController: UIViewController {
    ...
    NSString *alertTitle;
    NSString *alertText;
    NSString *alertNumber;
    NSString *alertAddress;
...
}

@property (nonatomic, retain) NSString *alertTitle;
@property (nonatomic, retain) NSString *alertText;
@property (nonatomic, retain) NSString *alertNumber;
@property (nonatomic, retain) NSString *alertAddress;
...

And here is the console output during this process if it helps….

    > 2010-10-29 11:09:17.954 [2672:307] http://maps.google.com/maps?q=123%20Main%20Street%0ASuite%20A,+Tampa,+FL+11111
    > 2010-10-29 11:09:21.657 [2672:307] Map Selected   
    > Program received signal:  “EXC_BAD_ACCESS”.
    > kill quit
  • 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-17T22:14:18+00:00Added an answer on May 17, 2026 at 10:14 pm

    Use setter so instance will be retained. Remember to release it, when you no longer need it.

    self.alertAddress = [[NSString stringWithFormat:@"http://maps.google.com/maps?q=%@,+%@,+%@+%@",a,b,c,d] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    

    Do the same with other properties.

    The other thing is that it seems you have memory leak:

    UIAlertView *phoneAlert = [[UIAlertView alloc] initWithTitle:alertTitle message:alertText delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Call",@"View Map",nil];
    [phoneAlert show];
    //add release after showing alert
    [phoneAlert release]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a weird problem I have started having recently. My team is developing
This is a really weird problem that I have been having. When I download
Here is the issue I am having: I have a large query that needs
I have been having some issues with LINQ-To-SQL around memory usage. I'm using it
I have been having some problems trying to get my PHP running. When I
I have being having trouble with the web server used for our intranet. It
I have to compute at libraries quite often these days, and have been having
I have recently started having problems with TortoiseCVS, or more specifically with plink, the
One of the problems I have come across having complex tasks on the browser
I have a huge web app that is having issues with memory leak in

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.