Re: ARC, blocks, capture variables

2015-09-28 Thread Quincey Morris
On Sep 28, 2015, at 17:33 , Scott Ribe wrote: > > Ah, I just tried assignment to weak ivar then registration, gets the same > value. Anyway, avoiding monkeying with temp vars to fool the compiler is why > I re-did the API. I’d say that the monkeying comes from ensuring you get the same pointer

Re: ARC, blocks, capture variables

2015-09-28 Thread Scott Ribe
On Sep 28, 2015, at 6:24 PM, Quincey Morris wrote: > > On Sep 28, 2015, at 17:14 , Scott Ribe wrote: >> >> "Assigning block literal to a weak variable; object will be released after >> assignment" > > Well, you wouldn’t assign a literal there. You want the exact same block > pointer for bot

Re: ARC, blocks, capture variables

2015-09-28 Thread Scott Ribe
> On Sep 28, 2015, at 5:53 PM, Quincey Morris > 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

Re: ARC, blocks, capture variables

2015-09-28 Thread Quincey Morris
On Sep 28, 2015, at 15:20 , Scott Ribe wrote: > > The essential problem was in the library design, not the calls. I was keeping > self.authfun as an instance var for the sole purpose of unregistering the > callback when the owner (a window controller) was being torn down. The better > way (IMO

Re: ARC, blocks, capture variables

2015-09-28 Thread Scott Ribe
On Sep 27, 2015, at 7:51 PM, Scott Ribe wrote: > > On Sep 27, 2015, at 7:03 PM, Quincey Morris > wrote: >> >> IIRC you can simply assign ‘self’ to a local variable just before assigning >> to ‘fun', and use the local variable name instead of ‘self’ inside the block. > > Well, that does work

Re: ARC, blocks, capture variables

2015-09-27 Thread Scott Ribe
On Sep 27, 2015, at 7:03 PM, Quincey Morris wrote: > > IIRC you can simply assign ‘self’ to a local variable just before assigning > to ‘fun', and use the local variable name instead of ‘self’ inside the block. Well, that does work. Thanks! -- Scott Ribe scott_r...@elevated-dev.com http://w

Re: ARC, blocks, capture variables

2015-09-27 Thread Quincey Morris
On Sep 27, 2015, at 17:17 , Scott Ribe wrote: > > But I know that it does not result in a retain cycle, because I nil out fun > at the appropriate time. So how to get rid of the warning? IIRC you can simply assign ‘self’ to a local variable just before assigning to ‘fun', and use the local va

ARC, blocks, capture variables

2015-09-27 Thread Scott Ribe
Given a block instance var named fun: fun = ^void () {[self ...];}; Results in the warning: "Capturing 'self' strongly in this block is likely to lead to a retain cycle" But I know that it does not result in a retain cycle, because I nil out fun at the appropriate time. So how to get rid of th