> On Aug 10, 2016, at 12:10 PM, Gurkan Erdogdu <gurkanerdo...@yahoo.com> wrote:
> 
> I try to get file close notification in Cocoa/Swift. Is there any way to do 
> this? I tried to use FSEvent API but this does not provide any notification 
> for file close events.

I don’t think there’s any such notification. File handles are private to a 
process.

> Any help is appreciated. What I want to do is when word or PDF file is 
> closed, I want my Cocoa application do sometnig?

If you want to do something when the file is changed, then watch for 
file-changed events. You’ll probably want to wait a few seconds after the last 
such event, because you may get several in a row if the changes take a while 
(for example if a file is being downloaded.)

If you want to do something when a _document_ is closed in an app like Preview 
or Word, that’s entirely different. Closing a document has nothing to do with 
closing a file. When most apps open a document they open the file, read its 
contents, and then close the file. They don’t leave it open while the document 
is open. As far as I know there is no reliable way to detect when some other 
app closes a document.

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to