• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa File Close Notification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa File Close Notification


  • Subject: Re: Cocoa File Close Notification
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 10 Aug 2016 12:30:46 -0700

> 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


  • Follow-Ups:
    • Re: Cocoa File Close Notification
      • From: Sandor Szatmari <email@hidden>
References: 
 >Cocoa File Close Notification (From: Gurkan Erdogdu <email@hidden>)

  • Prev by Date: Cocoa File Close Notification
  • Next by Date: Re: Dynamic-width Collection View
  • Previous by thread: Cocoa File Close Notification
  • Next by thread: Re: Cocoa File Close Notification
  • Index(es):
    • Date
    • Thread