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

Re: NSSavePanel beginSheetForDirectory:


  • Subject: Re: NSSavePanel beginSheetForDirectory:
  • From: Brian Webster <email@hidden>
  • Date: Fri, 2 Aug 2002 09:00:28 -0500

On Thursday, August 1, 2002, at 06:01 PM, cocoa-dev-
email@hidden wrote:

I'm having trouble implementing -beginSheetForDirectory: The only sample
project I can find that uses it is TextEdit, which uses it in a way so
fantastically sophisticated I can't make head or tail of it. Could
somebody suggest how I could replace the following implementation of
-runModalForDirectory: with a sheet?

Because sheets are not application modal (i.e. the user can still perform actions in other windows while a sheet is up), you have to first call the method to bring up the sheet, and then implement another method which is called when the sheet is dismissed. That is whet the didEndSelector is for. Here's an example:

-(IBAction)saveAllNotes:(id)sender
{
NSSavePanel *panel = [NSSavePanel savePanel];
NSMutableString *compiledNotes = //etc.

[panel beginSheetForDirectory:NSHomeDirectory()
file:@"Compiled Notes.txt"
modalForWindow:[self window]
modalDelegate:self
didEndSelector:@selector(saveNotesSheetEnded:returnCode:contextInfo:)
contextInfo:compiledNotes];
}

-(void)saveNotesSheetEnded:(NSSavePanel*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo
{
if(returnCode == NSOKButton)
{
[(NSString*)contextInfo writeToFile:[sheet filename] atomically:YES];
}
[NSApp endSheet:sheet];
[sheet close];
}

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.

  • Prev by Date: Re: how do i read and send data through a serial port (using a keyspan adaptor)
  • Next by Date: InfoPlist.strings
  • Previous by thread: Re: NSSavePanel beginSheetForDirectory:
  • Next by thread: Returning an error from Applescript
  • Index(es):
    • Date
    • Thread