Re: Cocoa File Close Notification
Re: Cocoa File Close Notification
- Subject: Re: Cocoa File Close Notification
- From: Sandor Szatmari <email@hidden>
- Date: Wed, 10 Aug 2016 16:50:50 -0400
Have you considered using a dispatch source?
You might have to do some manual checking when you get a notification about activity with your file, but it might be suitable to your needs.
Here's a link I was reading:
http://stackoverflow.com/questions/11355144/file-monitoring-using-grand-central-dispatch
Sandor Szatmari
> On Aug 10, 2016, at 15:30, Jens Alfke <email@hidden> wrote:
>
>
>> On Aug 10, 2016, at 12:10 PM, Gurkan Erdogdu <email@hidden> 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 (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
_______________________________________________
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