On Fri, May 30, 2008 at 3:33 PM, John Love <[EMAIL PROTECTED]<[EMAIL PROTECTED]>> wrote:
> Here's some code snippets that I'm having problems with .. the code is > sorta working in that an alert *window* appears, but not as a drop-down > sheet as I think the following calls for: (and even when erroneously a > window, it is behind the main document window) > > Two controllers .. FileController and SheetController .. > > 1) FileController.h contains > IBOutlet SheetController *theSheet; .. and .. NSWindow > *itsWindow; (FileController's itsWindow gets set within MyDocument.m which > passes its IBOutlet NSWindow *documentWindow to a method of > FileController) As a result, MyDocument's documentWindow becomes > FileController's itsWindow > > 2) FileController.m contains > [theSheet showCalculateSheet:itsWindow]; > > 3) SheetController.h contains > - (void) showCalculateSheet:(NSWindow*)docWindow; > > 4) SheetController.m contains > > - (void) showCalculateSheet:(NSWindow*)docWindow { > NSAlert *calculateSheet = [[[NSAlert alloc] init] autorelease]; > > [calculateSheet addButtonWithTitle:@"Continue"]; > [calculateSheet addButtonWithTitle:@"Stop and save"]; > [calculateSheet addButtonWithTitle:@"Stop and don't save"]; > [calculateSheet setMessageText:@"You have not finished calculating > your Spreadsheet.\n" > "Do you wish to continue > calculating?"]; > [calculateSheet setAlertStyle:NSWarningAlertStyle]; > > [calculateSheet beginSheetModalForWindow:docWindow modalDelegate:nil > didEndSelector:nil // > @selector(endCalculateSheet:code:info:) > contextInfo:nil]; > } > > // *if* I use a real selector method, and not nil, I cannot dismiss the > alert > > - (void) endCalculateSheet:(NSWindow*)theSheet code:(int)returnCode > info:(void*)contextInfo { > > if (returnCode == NSAlertDefaultReturn) { // "Continue" > > } else if (returnCode == NSAlertOtherReturn) { // "Stop and save" > > } else if (returnCode == NSAlertAlternateReturn) { // "Stop and don't > save" > > } > > [theSheet orderOut:self]; > > } > > Thanks for everything in advance .. > > John Love > > > Jens wrote: My guess is that docWindow is nil. Set a breakpoint and check. But follow-ups should go to the list. John wrote back if (docWindow != nil) NSLog(@"passed window is not nil"); produced the log string. Touch the Future! Teach!! _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]