The other day I was writing an AppleScript and noticed that AppleScript's 'choose file' command has a parameter 'of type' which requires a UTI. Since I'd like to be able to use this parameter in AppleScripts that choose my app's documents, I read up on UTI [1]. It all seems very simple, including the fact that "if a suitable UTI does not exist, you can create your own".

Since my document type is proprietary, I opened the editor on my project's app target and, in the Properties tab, in the line for my app's single document type, I saw that the UTI was blank. So I changed it to com.MyCompanyBlah.Blah.

The results of this:

1. In my app's Info.plist, in the CFBundleDocumentTypes, in the single array for my single document type, there was added a key LSItemContentTypes, an array containing a single string, com.MyCompanyBlah.Blah. Per documentation, this is expected.

2. Before adding the UTI, -[NSDocumentController defaultType] returned the "Name" of my single document type. After, it returns its UTI. This is odd -- seems like we've got some wires crossed here. Indeed...

3. During running of -[NSDocumentController openUntitledDocumentAndDisplay:error], for example, to create a new document, it raises an exception:
     *** -[NSPathStore2 stringByAppendingPathExtension:]: nil argument

Remove the UTI from the Target's Properties and now new documents can now be created again.

Why the strange reactions from NSDocumentController? Is this one of those situations where I need to kick Launch Services in the pants or something like that?

Sincerely,

Jerry Krinock


[1] http://developer.apple.com/macosx/uniformtypeidentifiers.html
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to