• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to specify document extension programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


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

  • Prev by Date: After inserting link into text, link continues as user types
  • Next by Date: Sorting array of strings by string length
  • Previous by thread: How to specify document extension programmatically
  • Next by thread: Attributed string not displaying with effects of attributes in an NSTextView...
  • Index(es):
    • Date
    • Thread