Re: Fire-and-forget controllers with blocks

2011-05-20 Thread Ken Thomases
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

Re: Fire-and-forget controllers with blocks

2011-05-20 Thread Ben
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

Re: Fire-and-forget controllers with blocks

2011-05-20 Thread Kyle Sluder
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

Re: Fire-and-forget controllers with blocks

2011-05-20 Thread Dave Zarzycki
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