我正在查看文档以找到如何允许放置在停靠图标上。从我所见,建议您使用 LSItemContentTypes,因为不推荐使用 CFBundleTypeOSTypes。但是,我无法让 LSItemContentTypes 工作,只有 CFBundleTypeOSTypes 为* * 才会接受丢弃。
我怎样才能以不弃用的方式做到这一点?
谢谢,尼克
我正在查看文档以找到如何允许放置在停靠图标上。从我所见,建议您使用 LSItemContentTypes,因为不推荐使用 CFBundleTypeOSTypes。但是,我无法让 LSItemContentTypes 工作,只有 CFBundleTypeOSTypes 为* * 才会接受丢弃。
我怎样才能以不弃用的方式做到这一点?
谢谢,尼克
这是我在我的应用程序的 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>
查看文档以了解每个键的确切作用。
CFBundleTypeName和CFBundleTypeRole是必需的。
LSItemContentTypes是一个UTI数组。要获取文件的 UTI,只需在终端中输入:
mdls -name kMDItemContentType /path/to/file
不要忘记调整CFBundleTypeRole和LSHandlerRank以满足您的需求。