I'm building a program that launches another program and is then supposed to monitor it, and take action if it terminates. When the application is launched, I can get an instance of NSRunningApplication from NSWorkspace.
Now, the documentation states that NSRunningApplication has the property 'terminated' that is key-value observable. I've tried implementing:
[browserInstance addObserver:self
forKeyPath:@"terminated"
options:NSKeyValueObservingOptionNew
context:NULL];
And:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
NSLog(@"observeValueForKeyPath");
if ([keyPath isEqual:@"terminated"])
{
NSLog(@"terminated");
}
}
but I never see the observeValueForKeyPath method get tripped. Does anyone know how to make this work, if it is possible? I haven't been able to find any specific examples anywhere online.