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
{
        MyImportController *controller = [[MyImportController alloc] init];
        [controller setCallbackTarget:self];
        [controller start];
}

- (void)importDone:(MyImportController *)aController
{
        // This method called from the controller
}




But what I've changed that to is this:


MyImportController *controller = nil;
CleanupBlock cleanup = ^{
        [controller release];
        // Other stuff
};
controller = [[MyImportController alloc] initWithCleanupBlock:[[cleanup copy] 
autorelease]];
[controller start];
// The controller calls cleanup() when it's done


It doesn't exhibit any problems that I can see, but the static analyzer 
complains that I'm leaking the controller object in the second example. Am I 
actually doing something wrong here? If not, is there a way to make analyzer 
recognise this?

- Ben

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to