Re: Excluding non-export file types from the Export dialog.
Re: Excluding non-export file types from the Export dialog.
- Subject: Re: Excluding non-export file types from the Export dialog.
- From: Bruno Di Gleria <email@hidden>
- Date: Tue, 17 Oct 2006 12:07:22 +0200
- Thread-topic: 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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden