My main program creates a thread that does the following:
NSArray *blah = [NSArray arrayWithObject: @"moo"];
[self performSelectorOnMainThread: @selector(boonk:) withObject: blah
waitUntilDone: NO];
Now this seems bad to me, because the autoplay pool can be released before the boonk: selector is finished, which will lead to a crash.
So my natural next step would be this:
NSArray *blah = [[NSArray alloc] initWithObject: @"moo"];
[self performSelectorOnMainThread: @selector(boonk:) withObject: blah
waitUntilDone: NO];
- (void)boonk: (id)data
{
[data release];
}
This is definitely error-free, but .... seems unnatural. Is there an objective-c agreement or reference counting protocol to handle this situation (forwarding a NO-wait stream), or is the second solution higher than how it was made?
source
share