Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to specify document extension programmatically



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >How to specify document extension programmatically (From: Patrick Rogers <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.