【发布时间】:2011-01-09 02:59:47
【问题描述】:
我正在查看文档以查找如何允许拖放到停靠图标上。根据我所见,建议您使用 LSItemContentTypes,因为不推荐使用 CFBundleTypeOSTypes。但是,我无法让 LSItemContentTypes 工作,只有 CFBundleTypeOSTypes 为 ** 它才会接受丢弃。
我怎样才能以不被弃用的方式做到这一点?
谢谢, 尼克
【问题讨论】:
标签: cocoa drag-and-drop dock
我正在查看文档以查找如何允许拖放到停靠图标上。根据我所见,建议您使用 LSItemContentTypes,因为不推荐使用 CFBundleTypeOSTypes。但是,我无法让 LSItemContentTypes 工作,只有 CFBundleTypeOSTypes 为 ** 它才会接受丢弃。
我怎样才能以不被弃用的方式做到这一点?
谢谢, 尼克
【问题讨论】:
标签: cocoa drag-and-drop dock
这是我在应用程序的 Info.plist 中使用的内容:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>SomeName</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>None</string>
<key>LSItemContentTypes</key>
<array>
<string>public.mp3</string>
</array>
</dict>
</array>
查看Documentation,了解每个键的具体作用。
CFBundleTypeName 和 CFBundleTypeRole 是必需的。
LSItemContentTypes 是一个 UTIs 数组。要获取文件的 UTI,只需在终端中输入:
mdls -name kMDItemContentType /path/to/file
不要忘记调整 CFBundleTypeRole 和 LSHandlerRank 以满足您的需求。
【讨论】: