• 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: alternative to NSURLConnection sendSynchronousRequest
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: alternative to NSURLConnection sendSynchronousRequest


  • Subject: Re: alternative to NSURLConnection sendSynchronousRequest
  • From: "Shawn Erickson" <email@hidden>
  • Date: Tue, 13 Jan 2009 16:44:58 -0800

On Tue, Jan 13, 2009 at 4:13 PM, Jerry Krinock <email@hidden> wrote:
>
> On 2009 Jan, 13, at 14:24, Kevin Gessner wrote:
>
>> On Jan 13, 2009, at 4:27 PM, JB wrote:
>>
>>> How can I force my code to wait for the asynchronous request to finish,
>>> without using sendSynchronousRequest?
>>
>> You can split your post-connection stuff into another method, and call it
>> from the delegate's implementation of connectionDidFinishLoading:. Then it
>> will be called only when the connection is complete.
>
> How will that cause the main thread to block, as JB desires?

It doesn't. The point is he really shouldn't have the main thread
block. He should have it be event driven. Start the request, go back
to the normal run loop, handle the notification when the request
finishes (or fails), and carry on with the next steps.

> My code for doing this starts the connection in a different thread, then
> enters an infinite loop which checks for either a response or a user
> cancellation every 50 milliseconds, breaking when either is received.

*cringe*

Polling like this is almost always a bad idea... Several better ways
exist to deal with this but which to use depends on what you are
attempting to do.

-Shawn
_______________________________________________

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: 
 >alternative to NSURLConnection sendSynchronousRequest (From: JB <email@hidden>)
 >Re: alternative to NSURLConnection sendSynchronousRequest (From: Kevin Gessner <email@hidden>)
 >Re: alternative to NSURLConnection sendSynchronousRequest (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: alternative to NSURLConnection sendSynchronousRequest
  • Next by Date: UTIs and type codes and extensions
  • Previous by thread: Re: alternative to NSURLConnection sendSynchronousRequest
  • Next by thread: Re: alternative to NSURLConnection sendSynchronousRequest
  • Index(es):
    • Date
    • Thread