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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:29:08+00:00 2026-05-28T08:29:08+00:00

I have an odd problem that is crashing my app, that I would like

  • 0

I have an odd problem that is crashing my app, that I would like some opinions on if possible.

I have an NSURLConnection, submitting POST data to an external PHP file and getting a response back that is displayed on the iPhone.

This all works fine, and can be done many times without error, without any leaks showing up in analysis and without any crashes.

The app also has an “email the response” option, and if this is pressed, the email program opens up, and that all works fine without issue as well.

However, on closing the email program and returning back to the main app again, if the “fetch data” button is now pressed, and the NSURLConnection done again, the app immediately crashes.

I can’t test this on the simulator, as it doesn’t open up the email program on the simulator – this is on real testing only on an iPhone. All tests and analysis done on within Xcode shows up fine and doesnt point to any issues.

All my code for the NSURLConnection to POST and retrieve the data is as follows:

- (void)FetchData {
result.text = @"";
emailbutton.hidden = YES;
emailbutton.enabled = NO;

NSString *queryStringFull = [queryStringFirst stringByAppendingString:textField.text];

NSURL *url = [NSURL URLWithString:@"http://www.mydomain.com/mypage.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSData *requestData = [queryStringFull dataUsingEncoding:NSUTF8StringEncoding];

[request setHTTPMethod:@"POST"];
[request setValue:@"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];
[NSURLConnection connectionWithRequest:(request) delegate:self];
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
responseData = [[NSMutableData alloc] init];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString* responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
if (![responseString isEqualToString:@"error"]) {
    result.text = responseString;
    emailbutton.hidden = NO;
    emailbutton.enabled = YES;
}
[responseString release];
[responseData release];
}

I would be very grateful for any ideas or thoughts on what is causing this, and how to solve it.

  • 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-28T08:29:08+00:00Added an answer on May 28, 2026 at 8:29 am

    Actually, it wasn’t the NSURLConnection at all!

    Turns out it was an image call that happens after the NSURLConnection call. The image was defined in viewdidload, released, and then was not defined after the app came back from the background.

    Adding a “retain” to the image definition in the viewdidload solved the issue!

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

Sidebar

Related Questions

I have the odd problem that I am not able to open the properties
I have an odd problem with Django. I have a set of objects that
Ok, so I have some problems with C++ iostreams that feels very odd, but
I have an odd problem. I have a unit test that keeps getting stuck
I have an extremely odd problem in my JUnit tests that I just can't
I have an odd problem that I've been beating my head into a wall
I have an odd problem in my jQuery code that loads in Drupal 7
I have an odd problem that I just can't seem to diagnose, and it
I have a slightly odd problem that I think is most likely due to
I have an odd problem. Our company collects data and we use a HORRIBLE

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.