• 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: Running NSURLConnection from within an NSOperation?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running NSURLConnection from within an NSOperation?


  • Subject: Re: Running NSURLConnection from within an NSOperation?
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 9 Feb 2010 22:08:29 -0800

On 2010 Feb 09, at 14:10, Greg Reichow wrote:

>> I'm trying to run an NSURLConnection from an NSOperation. Apparently, it won't run. I know that NSURLConnection need a run loop. Does that mean I'll have to setup some kind of NSTime in my NSOperation and then call my run loop at regular intervals?
>
> Try using the synchronous version of NSURLConnection since you are launching it from within a NSOperation already-
>
> + (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse**)response error:(NSError **)error

Indeed sendSynchronousRequest: will work for a quick hack to talk to, say, your own server, but if you hope to some day have a real app which predictably handles real-world corner cases, well, let me quote what was told to me once:

The NSErrors that you get from -sendSynchronousRequest: are not documented.  For example, if you give it a wrong  username/password combination, you get NSURLErrorUserCancelledAuthentication = -1012.  Apparently this is an implementation detail, that when it receives an authentication challenge, it cancels.  You're leaving the policy decisions to Apple instead of making them yourself, and since they are not documented, Apple may change them at any time.

It is true that the alternative asynchronous methods require a run loop.  (Don't use a timer).

_______________________________________________

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

  • Follow-Ups:
    • Re: Running NSURLConnection from within an NSOperation?
      • From: Greg Reichow <email@hidden>
References: 
 >Running NSURLConnection from within an NSOperation? (From: Laurent Daudelin <email@hidden>)
 >Re: Running NSURLConnection from within an NSOperation? (From: Greg Reichow <email@hidden>)

  • Prev by Date: Cocoaheads Lake Forest (92630) meeting TOMORROW, Wed 2/10/2010 at 7 pm on whiteboarding a Cocoa Touch application
  • Next by Date: Large queue of messages for another app
  • Previous by thread: Re: Running NSURLConnection from within an NSOperation?
  • Next by thread: Re: Running NSURLConnection from within an NSOperation?
  • Index(es):
    • Date
    • Thread