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

Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)


  • Subject: Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)
  • From: Keith Duncan <email@hidden>
  • Date: Tue, 22 Jun 2010 11:03:37 +0100

> I had a chicken and egg problem wrt initializing the handler (with a completion block that needed the connection) and the connection (which needed the handler).

In that circumstance you can decorate the variable that you need to reference inside the block as __block, and set it to nil. These variables aren't const copied, they are moved to the heap and referenced. When you assign to it in future lines, the block will reference the updated value.

Keith

_______________________________________________

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: 
 >Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?) (From: John Heitmann <email@hidden>)
 >Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?) (From: Kevin Wojniak <email@hidden>)
 >Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?) (From: John Heitmann <email@hidden>)

  • Prev by Date: Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)
  • Next by Date: Re: Threaded DOM operations
  • Previous by thread: Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)
  • Next by thread: Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)
  • Index(es):
    • Date
    • Thread