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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:23:05+00:00 2026-05-22T00:23:05+00:00

In one of my apps, I’d like to call asynchronously a php page I

  • 0

In one of my apps, I’d like to call asynchronously a php page I have written (http://serveradress/page.php?date=20111231), and I would be sure to know if the page could be called (no 404 error, php server down, customised 404 page, missing internet connection, or some things like that).
I’ve planned for that to make the php page return a very simple HTML page with just “OK” in its body or title.

This would be a “phantom” call without use of any UIWebView, or if REALLY nedded, a hidden UIWebView but I’d prefer to avoid this.

Could you help me to write this call ?
And be sure to know if it has been loaded ?

I saw that I should probably use NSURLConnection, but I’m a little bit lost.

Could you help me ?

  • 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-22T00:23:05+00:00Added an answer on May 22, 2026 at 12:23 am

    NSURLConection is very good solution for asynchronous loading. There are few steps for creating one.

    1. Setup your NSURLConnection

    - (void)viewDidLoad {
        // your code...
        responseData = [[NSMutableData alloc] init];
        NSURL *url = [NSURL URLWithString:@"http://yourdomain.com/"];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self]];
    }
    

    responseData is your NSMutableData iVar.

    2. Implement delegate methods

    a) In this method we will check for HTTP status codes

    - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
        if ([response respondsToSelector:@selector(statusCode)]) {
            int statusCode = [((NSHTTPURLResponse *)response) statusCode];
            if (statusCode >= 400) {
                [connection cancel]; 
                NSDictionary *errorInfo = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:NSLocalizedString(@"Server returned status code %d",@""),statusCode] forKey:NSLocalizedDescriptionKey];
                NSError *statusError = [NSError errorWithDomain:NSHTTPPropertyStatusCodeKey code:statusCode userInfo:errorInfo];
               [self connection:connection didFailWithError:statusError];
            }
        }
    }
    

    b) This creates your NSData component

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

    c) Handles successful url connection

    - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
        // do whatever you want using responseData as your server output
    }
    

    d) Handles errors

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

    You can get error info using [error userInfo] And display it in UIAlertView, for example.


    So as I said NSURLConnection is very good solution, but you should also look at ASIHTTPRequest library. 🙂

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

Sidebar

Related Questions

I would like to launch one of my apps inside a .bat file but
So we have a few (or more, no one knows) apps written by someone
I have built 2 apps: one for iPhone, one for iPad. They both build
In one of my Apps I do have a FileCache in a library project.
I have two apps (one for the iPhone, the other for the iPad) that
I have two WCF apps communicating one-way over named pipes. All is nice, except
In one of the apps of mine I have a performance problem I can’t
I have two cocoa-touch apps in one Xcode project. Xcode gives me iPhone/iPad related
I have changed one of my apps to use URL Rewrite 1.1 in IIS7.5
I had using phonegap to program one apps that try to call java function

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.