File types...
File types...
- Subject: File types...
- From: Randy Widell <email@hidden>
- Date: Mon, 26 Mar 2012 23:14:26 -0700
OK, this is killing me…primarily because I have had this working in other applications and cannot find the difference between this current application and others where it works.
I have an application that opens one file type, and I have the following document type declaration (anonymized):
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>My Document Type</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>com.MyDomain.MyApp.MyDocumentType</string>
</array>
<key>NSDocumentClass</key>
<string>MyDocumentClass</string>
</dict>
</array>
It is a custom UTI, so, of course, I export it:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.database</string>
</array>
<key>UTTypeDescription</key>
<string>My Document Type</string>
<key>UTTypeIdentifier</key>
<string>com.MyDomain.MyApp.MyDocumentType</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>myextension</string>
</array>
</dict>
</dict>
</array>
I have an assistant that walks the user through setting up a new document. When it is time to save the new document, I create a save panel and pass setAllowedFileTypes: a one-element array with "com.MyDomain.MyApp.MyDocumentType" in it. When the user types in the file name, the save panel correctly adds the extension.
After saving the document, I open it for the user with the document controller's makeDocumentWithContentsOfURL:ofType:error:. I pass it the URL and the "com.MyDomain.MyApp.MyDocumentType" UTI. The document opens correctly with the MyDocumentClass object and resources.
Now…everything goes wrong when I try to open a file. Opening the recently saved document just gives the error: "The document '…' could not be opened. My App cannot open files of this type." If I try to select the file in the open panel, the document is just gray.
I have tried creating test apps and they work fine. My other apps work. Clearly, I screwed something up in this project. I have deleted the document type information from the Info.plist and rebuilt it. I have tried all kinds of UTIs. Etc. etc. etc. I cannot seem to get the app to recognize that it can open these files.
Any help would be appreciated.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden