Re: ARC, blocks, capture variables
Re: ARC, blocks, capture variables
- Subject: Re: ARC, blocks, capture variables
- From: Scott Ribe <email@hidden>
- Date: Mon, 28 Sep 2015 18:32:32 -0600
> On Sep 28, 2015, at 5:53 PM, Quincey Morris <email@hidden> wrote:
>
> You lost me at “I”, because it’s not clear whether you are the library or the client at that point. Was ‘authfun’ a property of the window controller (the client/owner?) or something in the library?
>
> Is the ‘id’ in the new API a reference to the window controller/client/owner? And it’s keyed because the reference is literally a key in a dictionary inside the library whose value is a completion block?
Yes & yes. (Sort of, a C++ multimap actually, which is how one controller can have multiple callbacks registered.)
> Actually, I think I have it. Originally, the block pointer was the client identifier, but then you changed the identifier to an “arbitrary” pointer supplied by the client. So, originally, the client had to keep a reference to the block to serve as identifier later.
Yes & yes. (In fact, the new API takes any kind of pointer, id or void*, and does not take ownership.)
> I think your new API is superior, but I do want to ask: for the original API, why could not ‘authfun’ just have been weak?
I didn't think of that when working on it; that sounds like a good suggestion, BUT:
"Assigning block literal to a weak variable; object will be released after assignment"
:-P
--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice
_______________________________________________
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: | |
| >ARC, blocks, capture variables (From: Scott Ribe <email@hidden>) |
| >Re: ARC, blocks, capture variables (From: Quincey Morris <email@hidden>) |
| >Re: ARC, blocks, capture variables (From: Scott Ribe <email@hidden>) |
| >Re: ARC, blocks, capture variables (From: Scott Ribe <email@hidden>) |
| >Re: ARC, blocks, capture variables (From: Quincey Morris <email@hidden>) |