You were half-right with the over-releasing thing. All my code for
running the task is in a TaskController object, which was being
autoreleased after the task was run, but before the NSTaskDidTerminate
was sent. I'd registered the object as an observer for this
notification but not removed is as the observer in the dealloc method
for the class! It suddenly occurred to me that a notification was
being sent to a dealloc'd object.
Now I have the problem of my taskController being dealloc'd before the
task has finished (whether its in a new thread or not) so the
NSTaskDidTerminateNotification is not being received by the object. I
*could* call [self autorelease] in the -taskDidTerminate: method, but
that will violate the memory management conventions. I currently have
a class method that instantiates my TaskController object, this is
called from my NSDocument subclass. So NSDocument subclass calls: