Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift - MacOs application - add to finder contextual menu?

Before all, I'm very new in swift cocoa application.

I'm developing an MacOS application for my company, the goal of this is to open a file ("right-click -> open with my app") to process it.

But after couples of search, I'm not enable to find a way to do it. (I probably didn't search the good terms, but like I said I'm very new to this)

(I've done a similar things to windows, using the registers)

Somebody has an idea? link, documentation ?

Thanks !

like image 787
F4Ke Avatar asked Nov 14 '25 11:11

F4Ke


2 Answers

Please have a look at Document based applications. It is a huge topic: https://developer.apple.com/library/mac/documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011179-CH1-SW1

As soon you register for types of documents you app can open, this feature will work the same way as in Windows. I.e. if you register custom extension, you app will onep this file by default. If you specify lets say you app can open pictures, it will show up in "open with" right click popup menu.

Pay attention to document types registration. Here is an example from one of the books (Learning Swift 2016):

enter image description here

like image 53
Eugene Mankovski Avatar answered Nov 17 '25 00:11

Eugene Mankovski


You can use finder extensions to do this. If you need more flexibility, you can use notifications to communicate with the main app and change right click menu items dynamically. Here is an app that uses the approach to add custom right click menu items. The page has a link to the source. finder extensions also have helpful examples.

like image 45
Makmeksum Avatar answered Nov 17 '25 00:11

Makmeksum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!