On May 20, 2011, at 9:10 AM, Dave Zarzycki wrote:
> One could naively and wrongly "fix" this by decoupling the init method:
>
> controller = [[MyImportController alloc] init];
>// "controller" is now non-nil and safe to capture
> [controller setCleanupBlock: ^{ [controller rel
On 20 May 2011, at 15:10, Dave Zarzycki wrote:
> On May 20, 2011, at 5:48 AM, Ben wrote:
>
>> MyImportController *controller = nil;
>> CleanupBlock cleanup = ^{
>> [controller release];
>> // Other stuff
>> };
>> controller = [[MyImportController alloc] initWithCleanupBlock:[[cleanup
On Fri, May 20, 2011 at 5:48 AM, Ben wrote:
> controller = [[MyImportController alloc] initWithCleanupBlock:[[cleanup copy]
> autorelease]];
Nitpick: the caller of -initWithCleanupBlock: should not be
responsible for the memory management of the block. Rather,
-initWithCleanupBlock: should copy
On May 20, 2011, at 5:48 AM, Ben wrote:
> MyImportController *controller = nil;
> CleanupBlock cleanup = ^{
> [controller release];
> // Other stuff
> };
> controller = [[MyImportController alloc] initWithCleanupBlock:[[cleanup copy]
> autorelease]];
> [controller start];
> // The con
Hi list,
I've been tidying up a codebase which can now make use of block-based APIs and
all is working quite nicely. However, in several places I have controllers
which I want to setup and launch and then clean up when they're done. What I
used to do was like this:
- (void)startImport
{