Re: static acting like __block in GCD singleton pattern
Re: static acting like __block in GCD singleton pattern
- Subject: Re: static acting like __block in GCD singleton pattern
- From: Matt Neuburg <email@hidden>
- Date: Sat, 29 Jun 2013 10:10:10 -0700
On Jun 29, 2013, at 10:00 AM, Kyle Sluder <email@hidden> wrote:
> In the first case, the block context captured the _value_ of a. In the
> second, it captured the _pointer to b's movable storage_.
That's a nice example, because it also focuses on the *other* practical aspect of __block, namely that it causes the value to be "live" in the block. This is often used, for example, in a one-time notification, to capture the observer token returned by creating the notification, and in the block, to use that token to remove the same observer - all in what amounts to one line of code.
I like the verbal distinction between capturing the value and pointing at the storage; I think that's where I need to go. It shows why __block both lets you modify the value and keeps the value live in the block; they are really just the same thing. Thx! m.
--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 6! http://shop.oreilly.com/product/0636920029717.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
_______________________________________________
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