I'm creating an application for Mac OS X, and I wanted to know whether I've used UTIs properly in the application's .plist file:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.petroules.silverlock.database</string>
<key>UTTypeDescription</key>
<string>Silverlock Database File</string>
<key>UTTypeIconFile</key>
<string>app.icns</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>com.apple.ostype</key>
<string>SDBX</string>
<key>public.filename-extension</key>
<array>
<string>sdbx</string>
</array>
<key>public.mime-type</key>
<string>application/octet-stream</string>
</dict>
</dict>
</array>
This code appears to work, although double-clicking a .sdbx file in Finder doesn't cause my application to open the file itself... but that might just be my code (something I'll look into later).
Also, the format of my file type is encrypted content encoded in base-64... is application/octet-stream the best MIME type to use for that or is there something else I should use, and could I possibly run into compatibility issues anywhere in the spectrum by using a less common MIME type?
Also, I included the following code:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>sdbx</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>app.icns</string>
<key>CFBundleTypeName</key>
<string>com.petroules.silverlock.database</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
开发者_StackOverflow社区 <key>LSItemContentTypes</key>
<array>
<string>com.petroules.silverlock.database</string>
</array>
<key>LSHandlerRank</key>
<string>Owner</string>
</dict>
</array>
Should I include this at all because I have the UTI code above? Is this necessary? What are the differences between the two? I wasn't really able to ascertain that from the documentation. Thanks :)
To find out whether this or your code is at fault, quit your app before double-clicking on the file. If this launches your app but doesn't open the file, then your Info.plist
is fine and your problem is in -[[NSApp delegate] application:openFile:]
. If the app doesn't launch at all, you can be sure that your Info.plist
isn't correct as far as Launch Services is concerned.
You do need both the UTExportedTypeDeclarations
and CFBundleDocumentTypes
stanzas. The first one tells Launch Services that your custom UTI exists. The second tells it that your app is an editor for that file type.
精彩评论