我正在寻找一个指南或样例代码来编写Mac OS X Finder插件?它想知道如何做一些简单的动作:

  1. 向图标添加图像覆盖层
  2. 添加上下文菜单项
  3. 收听文件更改

我发现了以下两个资源:

我很想查看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上运行,所以在雪豹发布之前看看它可能是有意义的.

Objective-c相关问答推荐

在 Objective-C 中实现纯虚方法

Objective-C 和 Cocoa 有什么区别?

静态和动态单元格的 UITableView 混合?

Objective C 代码是否有 github markdown 语言标识符?

在 UILabel.attributedText *not* 蓝色和 *not* 下划线

iOS中CALayer的UIImage

右对齐的 UITextField 空格键在 iOS 7 中不前进光标

NSUserDefaults 的限制是什么?

使用正则表达式在 Xcode 中查找/替换

在Objective-C中替换字符串中的多个字符?

当服务器上的图像文件更改时,我的应用程序中的 SDWebImage 缓存图像会发生什么情况?

iOS 5:对 UIAppearance 感到好奇

Objective C 中的调用方法或发送消息

如何从 UIGestureRecognizer 获取 UITouch 位置

如何本地化 iOS 故事板

如何判断数组是空还是空?

为什么使用弱指针进行委托?

performFetchWithCompletionHandler 永远不会被解雇

移除所有 CALayer 的子层

未调用 cellForItemAtIndexPath 但 numberOfItemsInSection 调用