Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate Finder Sync Extensions with Xcode in Cocoa

I want to use Finder Sync Extensions exactly like Dropbox like add toolbar icon and update the badge icons while syncing using Objective C in Xcode.
I searched in google a lot but I could not found any sample code related to this.

I found only one link for that Finder Sync.

But i want to know the sample procedure to integrate Finder Sync Extension as an example or code for more understanding.

Thanks in adv..!!

like image 381
jigs Avatar asked Apr 07 '15 13:04

jigs


1 Answers

I am the author of Seafile's Finder Sync Extension code. Thanks for post the link to my code. I have improved the code overtime since the first publish.

The architecture is much simpler than what's the windows' explorer extension programming. Firstly you need to tell Finder (or FIFinderSyncController) which directories you want to watch (via setting directoryURLs), and the FIFinderSyncController will callback via beginObservingDirectoryAtURL when the user visits some directory in Finder. Then if the specific files in the directory are visited the first time after requestBadgeIdentifierForURL call, you will be called back with requestBadgeIdentifierForURL. You should record this information if you want to update the badge later. Finally you can set badge on your files whenever possible in the main queue via setBadgeIdentifier.

Another important thing to mention is, as the official document says, that the Extension is running in another process (neither the threads from Finder nor those from your apps) and talking with Finder via XPC. And you might need to interact with your extension via some kind of IPC such as XPC or mach ports since the extension is required to be sandboxed.

I hope this information will help you with your code.

like image 191
Chilledheart Avatar answered Sep 20 '22 23:09

Chilledheart