• 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: Setting a documents file type during save as=8 5
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting a documents file type during save as=8 5


  • Subject: Re: Setting a documents file type during save as=8 5
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Wed, 14 Jan 2004 02:27:15 -0800

Hello...

/* * * * insert standard disclaimer about using undocumented API here * * * */

If you reverse engineer the default accessory view in the save panel, you can find out that the action of the popupMenuButton containing the possible filetypes is (at least as of @ 10.2)

- (void)changeSaveType:(id)sender;

and the target is your document. If I remember correctly, the title of the menu items does not matter, but each menuItem's representedObject needs to be an NSString containing the correct type name.

So, if you are willing to accept the risk that your code may break in the future (in the hope that NSDocument's changeSaveType: is eventually documented and becomes another one of those wonderful "been in the runtime since before you were born" methods), you can use that info to modify the existing popupMenu, or make your own accessory view and popup use the undocumented API.

Also, you might need to override the NSDocumentController methods that match filetypes/extensions, or take care of dealing with the appropriate file extensions yourself.

Hope that helps,

Louis


On Jan 13, 2004, at 15:42, mmalcolm crawford wrote:

On Jan 13, 2004, at 11:51 AM, Jonathan Wight wrote:

In my NSDocument's -prepareSavePanel method I'm adding a pop-up menu to
allow the user to select the format to save the document as.

Is there any reason why the alternate options are not presented automatically?
If you want to support write-only formats, look for NSExportableAs.
<http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/
Tasks/FAQ.html> etc.

The problem with that method is that not all the types I support will be present in my Application Info.plist. I have plug-in based exporters.

However I'm unsure where to make the changes necessary to actually
change the file type during the method that physically writes the file
(-[NSDocument writeToFile:ofType:] in this case).

You shouldn't change the type in that method -- you're given the type as one of the parameters...

What I ended up doing is setting/resetting a flag in - [NSDocument saveToFile:saveOperation:delegate:didSaveSelector:contextInfo:] and then checking for that flag in: -[NSDocument writeWithBackupToFile:ofType:saveOperation:] and if set then called [super writeWithBackupToFile:...] with a different type.

Fine until I find a better solution (although I like the idea of AppKit generating my popup menu for me).

Cheers.

Jon.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Setting a documents file type during save as=8 5 (From: Jonathan Wight <email@hidden>)
 >Re: Setting a documents file type during save as=8 5 (From: mmalcolm crawford <email@hidden>)
 >Re: Setting a documents file type during save as=8 5 (From: Jonathan Wight <email@hidden>)

  • Prev by Date: nspopupbuttoncell as textattachment
  • Next by Date: NSDate and Date formatters
  • Previous by thread: Re: Setting a documents file type during save as=8 5
  • Next by thread: CURLHandle trouble
  • Index(es):
    • Date
    • Thread