Re: How to specify document extension programmatically
Re: How to specify document extension programmatically
- Subject: Re: How to specify document extension programmatically
- From: Patrick Rogers <email@hidden>
- Date: Mon, 20 Feb 2006 15:11:07 -0500
I solved my own problem, and so I'm forwarding the answer to the list
in case anyone is ever looking (it was embarrassingly easy).
On 17-Feb-06, at 7:59 PM, Patrick Rogers wrote:
I was wondering if there was a way to do any of the following:
- Display a save dialog that used a specific file extension (while
preserving the normal save dialog behaviour vis a vis filename
extensions).
I configured the save dialog with a required file type in
[NSDocument prepareSavePanel]. Since the code is only needed when run
as a plug-in I check to see if the bundle that contains the document
class matches the class matches the main bundle to prevent modifying
the dialog when not necessary.
- (BOOL)prepareSavePanel:(NSSavePanel *)savePanel {
NSBundle *classBundle = [NSBundle
bundleForClass:NSClassFromString(@"MyDocument")];
if (classBundle != [NSBundle mainBundle]) {
/* If this is not located in the main bundle (ie: this is
being used */
/* as a plug-in for another application) then the main
info.plist */
/* file does not define the document type and the file dialog
will */
/* not know to restrict the file extension to fxstcl, so we
must */
/* restrict the file type manually.
*/
[savePanel setRequiredFileType:@"extension"];
}
return(YES);
} /* prepareSavePanel: */
- Pat
_______________________________________________
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