Hi All

I have several cases of the following pattern in my code:

- (void)start
{
        [[Something alloc] initWithDelegate:self];
}

- (void)finishWithSomething:(Something*)something
{
        [something release];
}

The intent of course is that the Something object calls back the caller with finishWithSomething: and that does the cleanup. Several UI classes can work this way e.g. -[UIActionSheet initWithTitle:delegate:...].

However as I understand it, there are several problems with this pattern:

1. The code is not GC friendly as between the end of start and the beginning of finishWithSomething, there are no references to the object, so it may be collected. 2. The static analyzer in Xcode 3.2 doesn't like the construction, thinking that the object is leaking from the start method.

Of course I could keep a reference to the something object in a field of the calling object, but I was hoping to avoid that -- the calling object may invoke start multiple times before each finishWithSomething:.

Any suggestions?






Cheers, Glen Low


---
pixelglow software | simply brilliant stuff
www.pixelglow.com
aim: pixglen
twitter: pixelglow

_______________________________________________

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