放下码头图标

Nic*_*son 4 cocoa drag-and-drop dock

我正在查看文档以了解如何允许删除停靠图标.从我所看到的,建议您使用LSItemContentTypes,因为不推荐使用CFBundleTypeOSTypes.但是,我无法使LSItemContentTypes工作,只有CFBundleTypeOSTypes为**它才会接受丢弃.

我怎么能以不推荐的方式做到这一点?

谢谢,尼克

ink*_*ket 6

这是我在我的应用程序的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>
Run Code Online (Sandbox Code Playgroud)

查看文档以查看每个键的确切功能.

CFBundleTypeNameCFBundleTypeRole是必需的.

LSItemContentTypes是一个UTI数组.要获取文件的UTI,只需在终端中键入:

mdls -name kMDItemContentType /path/to/file
Run Code Online (Sandbox Code Playgroud)

不要忘记调整CFBundleTypeRoleLSHandlerRank以满足您的需求.