Re: Releasing an NSTask
Re: Releasing an NSTask
- Subject: Re: Releasing an NSTask
- From: Peter Maurer <email@hidden>
- Date: Fri, 16 Jan 2004 04:31:49 +0100
When is an appropriate time to release an NSTask? When my program is
shutting down, it will dealloc the task ([myTask dealloc]), but when
should [myTask release] be called? Should it be called each time the
task has completed running? If so, will this effect any further runs
of the task?
Shouldn't NSTasks run only once?! I think it would be a good idea to
release the NSTask when it has terminated. You might want to have a
look at the NSTaskDidTerminateNotification notification, for
instance...
[[NSNotificationCenter defaultCenter] addObserver: aTarget selector:
@selector(taskDidTerminate:) name: @"NSTaskDidTerminateNotification"
object: nil];
... combined with...
- (void) taskDidTerminate: (NSNotification*) theNotification {
[[theNotification object] release]; // the terminated task is the
notification's object
}
But don't do this with tasks you created with NSTask's
launchedTaskWithLaunchPath:arguments:!
Peter Maurer.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.