My application uses the following NSApplicationDelegate
function.
- (void)application:(NSApplication*)sender openFiles:(NSArray*)filenames;
I want to use this function to enable the user to drag and drop image files onto the application icon in the dock.
How do I have to define certain file types in my plist
file to restrict them to be images? I found out the structure has to look something like this.
// 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>
I added it to the plist
file but it does not work. A popup window shows the following error message.
The document "test.jpg" could not be opened. MyApp cannot open files in the "JPEG image" format.
Further, I read in the documentation that there is public.image
which would be what I want to define.
Meanwhile, I found out that the plist
file only contains the key CFBundleDocumentTypes
if I create a Cocoa Application with the option "Create document-based application.". Can you please clarify what dependencies exist for the option?