• 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: Writing Files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing Files


  • Subject: Re: Writing Files
  • From: publiclook <email@hidden>
  • Date: Sun, 29 Jun 2003 22:17:38 -0400

Download the "Cocoa Programming" examples from http://www.cocoaprogramming.net/Downloads.html.

Chapter 9's example shows how to do all of the common file opening, closing, etc. operations with a GUI.

Here is sample code for saving a tiff file:
- (IBAction)saveDocumentAs:(id)sender

/*" Displays a Save panel to find out where the user wants to save the document's image data. If the user does not cancel the save, this method saves the image data at the specified location. "*/
{
NSSavePanel *savePanel;
NSString *documentDirectory = [[self documentPath] stringByDeletingLastPathComponent];
NSString *documentName = [[self documentPath] lastPathComponent];

savePanel = [NSSavePanel savePanel];
[savePanel setRequiredFileType:@"tiff"];
[savePanel setTreatsFilePackagesAsDirectories:NO];

if (NSOKButton == [savePanel runModalForDirectory:documentDirectory file:documentName])
{
[self _mySetDocumentPath:[savePanel filename]];
[self _mySaveDocumentData];
}
}

You could obviously change that to .ps files.

Another example from the same chapter shows how to do the same thing with a sheet instead of a panel.


On Sunday, June 29, 2003, at 09:40 PM, Tyson Tate wrote:

In my current Cocoa app, I'm using existing C code to write out PostScript files. This works fine with:

f = fopen("test.ps", "wb");

And then using the standard streams to write out etc etc.

My question is, how might I go about letting the user specify the location and name of that file using the standard MacOS X dialog > boxes?

-Tyson

--
Tyson Tate, Editor
Entropy Magazine
"Nourishment For The Starved."
http://www.entropymag.net
_______________________________________________
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: 
 >Writing Files (From: Tyson Tate <email@hidden>)

  • Prev by Date: Re: Writing Files
  • Next by Date: Re: Writing Files
  • Previous by thread: Re: Writing Files
  • Next by thread: Re: Newbie question
  • Index(es):
    • Date
    • Thread