• 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
Trouble with a save panel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trouble with a save panel


  • Subject: Trouble with a save panel
  • From: David Wood <email@hidden>
  • Date: Sat, 15 Mar 2003 19:09:54 -0500

"Cocoa Programming for Mac OS X" (Aaron Hillegass, 2nd printing) has an example on page 243 of getting a custom view to generate a PDF. I try it, and get kvetches in the following style:

2003-03-15 18:19:49.358 TypingTutor[1268] Exception raised during posting of notification. Ignored. exception: *** -[NSCFArray objectAtIndex:]: index (4) beyond bounds (0)

The save panel itself doesn't seem to respond correctly to mouse clicks, clicking either Cancel or Save buttons accomplishes nothing, and it doesn't even show all of the files and folders in the Browser; it just shows those referenced, even when you click elsewhere. In fact, it's run as a sheet:

- (IBAction)savePDF:(id)sender
{
NSSavePanel *panel = [NSSavePanel savePanel];
[panel setRequiredFileType:@"pdf"];
[panel beginSheetForDirectory:nil
file:nil
modalForWindow: [self window]
modalDelegate:self
didEndSelector:@selector(didEnd:returnCode:contextInfo:)
contextInfo:nil];
}

..and it shows on the screen like a regular dialog box, separate from the program's main window.

Under NSSavePanel in the documentation, under method beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector: contextInfo: , they explicitly mention:

didEndSelector should have the following signature:

- (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;

...but the sample code explicitly uses didEnd:returnCode:contextInfo: as a return method, and the code elsewhere matches it.

The example is more or less as it shows in the book (the only differences are in comments and #pragma marks that I have scattered through the source to organize it), and there's no errata on the Big Nerd Ranch site for that part of the book.

I'm using a PBG4 500MHZ (yes, I am an early adopter) with 512Mb RAM and a nearly full hard drive (I'm working on that, as soon as I can track down an IBM Travelstar 60GH) running Mac OS 10.2.4, and have all updates to the present including the latest Java enhancements. And if I've got contaminated frameworks on this thing, they're VERY selective; I did the sample using beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSel ector:contextInfo: in NSOpenPanel and that sucker worked.

<SARCASM>Is there *another* book I should be reading to understand what's going on here?</SARCASM>


--David http://skipjack.bluecrab.org/~dwood

"I have meditated, and gotten in touch with my inner bastard."
_______________________________________________
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.

  • Follow-Ups:
    • Re: Trouble with a save panel
      • From: Sherm Pendley <email@hidden>
    • Fun with File/Directory Owners
      • From: m <email@hidden>
    • Re: Trouble with a save panel
      • From: Scott Anguish <email@hidden>
  • Prev by Date: saving data
  • Next by Date: Re: Trouble with a save panel
  • Previous by thread: saving data
  • Next by thread: Re: Trouble with a save panel
  • Index(es):
    • Date
    • Thread