In my Obj-C App I'm using the following code to open a file in Pages (or any other Application):
[[NSWorkspace sharedWorkspace] openFile:theUrl withApplication:@"Pages"];
Mainly when bigger files are opened, this may take a few seconds to finish. So I want my Application to wait for Pages until it completely opened the file.
The following code is how I would love to do it:
[[NSWorkspace sharedWorkspace] openFile:theUrl withApplication:@"Pages" onFinish:@selector(pagesfinishedopening)];
Of course I could simply use the sleep() function, but this would slow down the app on small files and would not work when the files are bigger than excepted.
I already tried something with the NSApplication, but then the opening of the file in Pages is not respected, only the start of the target application can be monitored.
Any Ideas?
You can listen for notifications arriving from NSWorkSpace like shown below