• 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 Asynchronous vs. Synchronous Asymmetry
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection Asynchronous vs. Synchronous Asymmetry


  • Subject: Re: NSURLConnection Asynchronous vs. Synchronous Asymmetry
  • From: Jens Alfke <email@hidden>
  • Date: Sun, 7 Mar 2010 09:28:57 -0800

On Mar 5, 2010, at 7:54 PM, Stuart Malin wrote:

> I expected the sendSynchronousRequest approach to return an NSHTTPURLResponse object without an error because, according to the docs, the synchronous method is built on top of the asynchronous methods.

Yes, but its semantics are different; it's more limited because it doesn't support a delegate. In particular, you can't do HTTP authentication with the synchronous version. Therefore, any 401 response by the server is a fatal error that gets returned to you. But in the async case, a 401 is a recoverable situation because you can implement the authentication method in the delegate API to handle it.

In general, the async API does not treat HTTP status conditions (4xx, 5xx) as errors; instead you can check for these in your didReceiveResponse method. But the synchronous version does return those as NSErrors.

—Jens_______________________________________________

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 Asynchronous vs. Synchronous Asymmetry (From: Stuart Malin <email@hidden>)

  • Prev by Date: Re: cocoa-dev vs. Apple's dev forums?
  • Next by Date: Re: predicate for a Core Data fetch request rejected by SQL
  • Previous by thread: Re: NSURLConnection Asynchronous vs. Synchronous Asymmetry
  • Next by thread: Quotation marks in NSMenu
  • Index(es):
    • Date
    • Thread