Re: Async NSURLConnection and blocks (was: Running NSURLConnection from within an NSOperation?)
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