1

I'm writing a document-based Mac application that can open any type. My application receives dropped files of any type on its Dock tile successfully, but when I choose Open from the File menu, all files are grayed out.

It's the standard Open item that comes with the template; I haven't put anything special behind it.

Here's the relevant part of my Info.plist:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFile</key>
        <string></string>
        <key>CFBundleTypeName</key>
        <string>Any file</string>
        <key>CFBundleTypeOSTypes</key>
        <array>
            <string>****</string>
        </array>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSTypeIsPackage</key>
        <false/>
        <key>NSDocumentClass</key>
        <string>MyDocument</string>
    </dict>
</array>

I have a custom document controller; here's its implementation.

- (Class) documentClassForType:(NSString *)documentTypeName {
    return [MyDocument class];
}

- (NSString *) typeForContentsOfURL:(NSURL *)inAbsoluteURL error:(NSError **)outError {
    return @"Any file";
}

These methods are not called at any time unless I drop a file on the Dock tile.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370

1 Answers1

1

In your NSDocumentController subclass, override runModalOpenPanel:forTypes: and just call super with nil for the types array. That will enable all file names in the NSOpenPanel.

willbur1984
  • 1,418
  • 1
  • 12
  • 21