views:

434

answers:

2

The only way I've been able to get this working is with a document-based application (which this app isn't). In my non-document-based application I've defined the supported Document Types (from the Properties tab of the Target info window) and my AppDelegate implements application:openFile: and application:openFiles:. That enables dropping files on the application's Dock icon when it has already been launched but not its icon in the Finder (launched or otherwise). What am I missing?

Updated

As requested, my Document Types array:

<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>nsf</string>
            <string>nsfe</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>NSF Soundtrack</string>
        <key>CFBundleTypeRole</key>
        <string>None</string>
        <key>LSTypeIsPackage</key>
        <false/>
        <key>NSPersistentStoreTypeKey</key>
        <string>InMemory</string>
    </dict>
</array>
A: 

In your Target settings, go to the Properties tab and add to the Document Types table.

Ben Gottlieb
I've already done that. "...my AppDelegate defines the Document Types it supports..."
Shaun Inman
oh, sorry, I didn't realize you meant the plist there.
Ben Gottlieb
No worries, the way I worded it originally didn't make it clear.
Shaun Inman
A: 

Two parts of this make me suspicious:

    <key>CFBundleTypeRole</key>
    <string>None</string>

Don't you mean this to be Viewer at least?

    <key>NSPersistentStoreTypeKey</key>
    <string>InMemory</string>

What are you trying to do here? Why would your on-disk file be specified as an in-memory Core Data persistent store? If you want to just hoist the whole thing into memory when you load it, that's called Binary or XML, not InMemory.

I also recommend that you define UTIs for your document types, not just extensions.

You should also double-check what Launch Services thinks is going on by using lsregister. Sometimes the problem is that you have multiple versions of your app lying around and Launch Services hasn't found the one you think it should have. You can look the Launch Services database like this: /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump

This should work on 10.5 and 10.6. 10.4 has lsregister in a different place. I usually use locate to find it rather than trying to memorize it.

Rob Napier
Thanks for the extra info. How do I determine the UTI of an esoteric file format I didn't create? Is something like `public.data public.item` enough in this case? `mdls megaman.nsf` returns `kMDItemContentType = "dyn.ah62d4rv4ge80665g"` Would I just use that?
Shaun Inman
You probably shouldn't invent a UTI for file formats you didn't create. I assumed this was your own file type.
Rob Napier