Hi,
I'm having some trouble with custom sheets in Cocoa. Basically, I've set up an custom sheet with a button that closes it. Every time I close the sheet I get the following error message: endSheet:returnCode: requires a non-nil sheet
without the sheet closing.
The structure of my project is kind of like this:
It contains nib file named Input.xib with some unimportant stuff on it, except for a button that triggers a close action via an object named InputController (A class that controls the stuff in the window). The Files Owner's class is set to OutputController, which is sort of the the main controller class.
The stripped down .m file of InputController looks like this:
Then we have the OutputController class, which is a Controller class for an output window, which is the window the sheet is displayed on.
In the OutputController .h file I have set up an IBOutlet @property of an NSWindow named inputSheet. It is connected to Window in the Input.xib file via the Files Owner (The Output Controller).
The stripped down .m file looks like this:
So why is my _inputSheet nil when endSheet: is called?
P.S: I sort of did what the documentation said: https://developer.apple.com/library...ts.html#//apple_ref/doc/uid/20001290-BABFIBIA
I'm having some trouble with custom sheets in Cocoa. Basically, I've set up an custom sheet with a button that closes it. Every time I close the sheet I get the following error message: endSheet:returnCode: requires a non-nil sheet
without the sheet closing.
The structure of my project is kind of like this:
It contains nib file named Input.xib with some unimportant stuff on it, except for a button that triggers a close action via an object named InputController (A class that controls the stuff in the window). The Files Owner's class is set to OutputController, which is sort of the the main controller class.
The stripped down .m file of InputController looks like this:
Code:
#import "InputController.h"
#import "OutputController.h"
@implementation InputController
- (id)init
{
self = [super init];
if (self) {
outputController = [[OutputController alloc] init];
}
return self;
}
- (IBAction)close:(id)sender { // The close button action
[outputController closeInputWindow];
}
@end
Then we have the OutputController class, which is a Controller class for an output window, which is the window the sheet is displayed on.
In the OutputController .h file I have set up an IBOutlet @property of an NSWindow named inputSheet. It is connected to Window in the Input.xib file via the Files Owner (The Output Controller).
The stripped down .m file looks like this:
Code:
#import "OutputController.h"
#import "InputController.h"
@synthesize inputSheet = _inputSheet;
- (void)activateInputWindow {
if (!_inputSheet) {
[NSBundle loadNibNamed:@"Input" owner:self];
}
[NSApp beginSheet:_inputSheet modalForWindow:[NSApp keyWindow] modalDelegate:self didEndSelector:nil contextInfo:nil];
}
- (void)closeInputWindow {
[NSApp endSheet:_inputSheet]; // This produces the error message
[_inputSheet close];
_inputSheet = nil;
}
@end
So why is my _inputSheet nil when endSheet: is called?
P.S: I sort of did what the documentation said: https://developer.apple.com/library...ts.html#//apple_ref/doc/uid/20001290-BABFIBIA