我正在寻找一个指南或样例代码来编写Mac OS X Finder插件?它想知道如何做一些简单的动作:
- 向图标添加图像覆盖层
- 添加上下文菜单项
- 收听文件更改
我发现了以下两个资源:
-
Writing Contextual Menu Plugins for OS X:2002年的一份过时文件,使用了针对Mac OS X 8/9的
COM
API. - SCPlugin:包含Finder插件的开源SVN Mac应用程序.
我很想查看SCPlugin
代码,但希望找到一个更容易理解的示例.
我正在寻找一个指南或样例代码来编写Mac OS X Finder插件?它想知道如何做一些简单的动作:
我发现了以下两个资源:
COM
API.我很想查看SCPlugin
代码,但希望找到一个更容易理解的示例.
Sadly, programming a Finder plugin actually does still require getting your hands dirty with COM. If you look at the SCFinderPlugin subproject of the SCPlugin project, you will find that it follows exactly the same techniques outlined in your first link, including setting up a vtable for COM, writing AddRef/ReleaseRef functions, and so on. Writing a plugin, where you're simultaneously managing old-school Carbon memory management, COM-style memory management, and Cocoa/new-style Carbon memory management, can be an incredible pain—and that totally ignores the fact that you'll be interacting in three or more radically different APIs, with different naming conventions and calling semantics. Calling the situation hysterically poor would be a vast understatement.
好的一面是,Mac OS X 10.6 Snow Leopard中的Finder已经用Cocoa完全重写了——随之而来的是非常优秀的插件接口.如果你足够幸运,实际上只能针对雪豹,你可能应该获得ADC Premier或更高级别的会员资格,下载预发布版本,并针对该版本编写代码.此外,如果没有Cocoa重写,你的插件可能无法在10.6上运行,所以在雪豹发布之前看看它可能是有意义的.