Re: NSSaveView and odd NSCFArray errors
Re: NSSaveView and odd NSCFArray errors
- Subject: Re: NSSaveView and odd NSCFArray errors
- From: Adam Knight <email@hidden>
- Date: Thu, 18 Sep 2003 11:33:28 -0500
Concerning this, I think I'm closer. It appears that the document
object is not used properly when a menu item is selected. That is,
when there's a button on the document window then all the methods talk
to the right document object, but when a menu is selected it does not
talk to the right object and, hence, I get funkyness like the below.
Key clue: it never appeared as a sheet. Always a floating window, even
though the document's window object was being passed.
So, questions:
1. What is the proper way to make a menu item talk to the frontmost
document (not key window, the document object)?
2. How bad is it to make all menu items have a firstResponder entry?
That works well to solve #1 in practice, but it seems like a hack.
On Wednesday, September 17, 2003, at 08:30 PM,
email@hidden wrote:
I have the following code:
- (IBAction)saveAIFF:(id)sender
{
NSSavePanel * panel = [NSSavePanel savePanel];
[panel setRequiredFileType:@"aiff"];
[panel beginSheetForDirectory:NSHomeDirectory()
file:@"Untitled.aiff" modalForWindow:fWindow modalDelegate:self
didEndSelector:@selector(didEndSaveSheet:returnCode:contextInfo:)
contextInfo:@"AIFF"];
}
- (void)didEndSaveSheet:(NSSavePanel *)theSavePanel
returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
NSLog(returnCode);
}
The sheet comes up properly but AFTER that the icons in the columns go
away, the text grays out, and any input (keyboard or clicking) cause
the following error to pop up in the console:
2003-09-17 00:43:22.258 MyProject[522] Exception raised during posting
of notification. Ignored. exception: *** -[NSCFArray objectAtIndex:]:
index (4) beyond bounds (0)
I've seen this question asked before in the archives and it was solved
with a bit of code. I tried that code almost verbatim (changed the
window object) and have the same issue. I have no idea what's going
on. This is a Cocoa Document-based app and the first function is
triggered from a menu item.
Anyone else run into this? Granted, this is my first attempt at using
this function, but it really shouldn't be this hard. This is exactly
how other programs seem to use it and it seems only this one fails, so
it's obviously something I'm monkeying but I have no idea what it could
be. I started with this:
[[NSSavePanel savePanel] beginSheetForDirectory:@"" file:@""
modalForWindow:fWindow modalDeligate:self
didEndSelector:@selector(didEndSaveSheet:returnCode:contextInfo:)
contextInfo:NULL];
It failed as well, hence me looking for other solutions. That same
code works in a sample project (the Clipboard Viewer one). I'm fairly
certain that I'm passing an argument wrong, but I can't figure out
which one.
Thanks for any help.
--
Adam
--
Adam
_______________________________________________
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.