我的应用程序使用以下NSApplicationDelegate
功能。
- (void)application:(NSApplication*)sender openFiles:(NSArray*)filenames;
我想使用此功能使用户能够将图像文件拖放到 Dock 中的应用程序图标上。
如何在我的plist
文件中定义某些文件类型以将它们限制为图像?我发现结构必须看起来像这样。
// plist file contents taken from Preview.app
[...]
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFile</key>
<string>jpeg.icns</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSIsAppleDefaultForType</key>
<true/>
<key>LSItemContentTypes</key>
<array>
<string>public.jpeg</string>
</array>
<key>NSDocumentClass</key>
<string>PVDocument</string>
</dict>
</array>
我将它添加到plist
文件中,但它不起作用。弹出窗口显示以下错误消息。
无法打开文档“test.jpg”。MyApp 无法打开“JPEG 图像”格式的文件。
此外,我在文档中读到public.image
了我想要定义的内容。
同时,我发现如果我使用“创建基于文档的应用程序”选项创建一个 Cocoa 应用程序,该plist
文件只包含密钥CFBundleDocumentTypes
。您能否澄清一下该选项存在哪些依赖项?