Re: Excluding non-export file types from the Export dialog.

  • Override NSDocument's writableTypes class method:

    + (NSArray *)writableTypes
    {
        NSArray *wTypes = [super writableTypes];
        NSMutableArray *wFilteredTypes = [wTypes mutableCopy];

        // remove native type //
        [wFilteredTypes removeObjectAtIndex:0];

        return (NSArray  *)wFilteredTypes;
    }

    > I've been looking for an answer to this for a week now. Nothing I come up with
    > seems to work. Surly others have come across this? How do you folks make your
    > export dialogs?
    >
    > Here's what I've done:
    >
    > I've set up an "Export AsŠ" menu in my application. I've wired it to First
    > Responder's saveDocumentTo:. I've added two file types (html and rtf) to my
    > info.plist, set their CFBundleTypeRole to "None", and put references to both
    > those type in NSExportableAs in my native file format. So the file section of
    > my info.plist looks like:
    >
    > <key>CFBundleDocumentTypes</key>
    > <array>
    > <dict>
    > <key>CFBundleTypeExtensions</key>
    > <array>
    > <string>native</string>
    > </array>
    > <key>CFBundleTypeIconFile</key>
    > <string>Native</string>
    > <key>CFBundleTypeMIMETypes</key>
    > <array>
    > <string>application/octet-stream</string>
    > </array>
    > <key>CFBundleTypeName</key>
    > <string>Native Type</string>
    > <key>CFBundleTypeRole</key>
    > <string>Editor</string>
    > <key>LSTypeIsPackage</key>
    > <false/>
    > <key>NSDocumentClass</key>
    > <string>MyDocument</string>
    > <key>NSExportableAs</key>
    > <array>
    > <string>HTML</string>
    > <string>RTF</string>
    > </array>
    > <key>NSPersistentStoreTypeKey</key>
    > <string>Binary</string>
    > </dict>
    > <dict>
    > <key>CFBundleTypeExtensions</key>
    > <array>
    > <string>html</string>
    > </array>
    > <key>CFBundleTypeName</key>
    > <string>HTML</string>
    > <key>CFBundleTypeRole</key>
    > <string>None</string>
    > <key>LSTypeIsPackage</key>
    > <false/>
    > <key>NSPersistentStoreTypeKey</key>
    > <string>InMemory</string>
    > </dict>
    > <dict>
    > <key>CFBundleTypeExtensions</key>
    > <array>
    > <string>rtf</string>
    > </array>
    > <key>CFBundleTypeName</key>
    > <string>RTF</string>
    > <key>CFBundleTypeRole</key>
    > <string>None</string>
    > <key>LSTypeIsPackage</key>
    > <false/>
    > <key>NSPersistentStoreTypeKey</key>
    > <string>InMemory</string>
    > </dict>
    >
    > When I select "Export AsŠ" from my menu, a standard save sheet pops out and
    > has a list of formats in a pop-up button as its accessory view. So far so
    > good.
    >
    > HOWEVER, in addition to "HTML" and "RTF" (listed in NSExportableAs), "Native"
    > also shows up in the file format popup. That's just wrong. If I wanted to
    > write the native format, I'd use Save or Save AsŠ, not Export AsŠ. In every
    > cocoa program I've ever used, the only file formats to appear in the export
    > dialog are the ones listed in NSExportableAs. Not the rest
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today