• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Releasing an NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Releasing an NSTask (From: Chad Armstrong <email@hidden>)

  • Prev by Date: Re: Releasing an NSTask
  • Next by Date: Canceling a pop-up menu, continued
  • Previous by thread: Re: Releasing an NSTask
  • Next by thread: Cocoa equivalent to TK canvas widget
  • Index(es):
    • Date
    • Thread