• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSURLConnection and 404
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection and 404


  • Subject: Re: NSURLConnection and 404
  • From: Koen van der Drift <email@hidden>
  • Date: Sun, 09 Jun 2013 05:43:22 -0400

On Jun 9, 2013, at 5:35 AM, Gerriet M. Denkmann <email@hidden> wrote:

> Is there a way to get just the status (in this case 404) without parsing the data?
> I looked at the NSURLConnection delegate methods, but did not find anything which looked appropriate.


I do something like this:

- (void) connectionDidFinishLoading:(NSURLConnection *)connection
{
        NSString *xmlString = [[NSString alloc] initWithData: receivedData encoding: NSUTF8StringEncoding];
        NSError *error = nil;

        if ([xmlString containsSubString: @"DOCTYPE"]) // the server gave an error in html format
        {
            error = [self serverErrorFromHTMLString: xmlString];
        }
        else
        {
          // no 404, etc status, so we can parse
            NSXMLParser *parser = [[NSXMLParser alloc] initWithData: receivedData];
	....
	}

	// show alert with error if needed
}


- Koen.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSURLConnection and 404 (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: NSURLConnection and 404
  • Next by Date: Re: NSURLConnection and 404
  • Previous by thread: NSURLConnection and 404
  • Next by thread: Re: NSURLConnection and 404
  • Index(es):
    • Date
    • Thread