• 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: Running an NSTask Within an NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running an NSTask Within an NSThread


  • Subject: Re: Running an NSTask Within an NSThread
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 27 Jan 2008 14:51:04 -0800

On Jan 27, 2008, at 14:06, Jonathan Dann wrote:

// NSDocument subclass implementation
- (IBAction)runTask:(id)sender;
{
TaskController *tC = [[TaskController defaultControllerForDocument:self];
[tC performTask];
}


...

This currently adheres to the memory management conventions, ...

Er, no, it doesn't. The (correctly autoreleased) TaskController has reference count 0, so is subject to disappearance anytime (for all practical purposes) after you return from runTask. What you really need to is make tC an instance variable of your document subclass, change runTask to say:


	tC = [[[TaskController defaultControllerForDocument:self] retain];

and find a suitable place for the TaskController to tell the document to release it (e.g. in taskDidTerminate). You also need to make sure that the document gets rid of any leftover TaskController in its dealloc, as well as in any other cases where the TaskController is not going to clean up after itself.

Or you could start using garbage collection and get an extra half hour's sleep tonight. :)

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Re: Running an NSTask Within an NSThread (From: Jonathan Dann <email@hidden>)

  • Prev by Date: Re: Running an NSTask Within an NSThread
  • Next by Date: Re: Running an NSTask Within an NSThread
  • Previous by thread: Re: Running an NSTask Within an NSThread
  • Next by thread: Re: Running an NSTask Within an NSThread
  • Index(es):
    • Date
    • Thread