cultures die entdeckung vinland crack
cultures die entdeckung vinland crackQ:
NSWindowController viewWillDisappear not called
I'm creating an application using NSWindowController. However, the viewWillDisappear is not called when the view is unloaded. What should I do? Here's my code.
#import "BlueController.h"
@implementation BlueController
- (void)awakeFromNib
{
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 500, 500) styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO];
// set the delegate
BlueController *controller = [[BlueController alloc] initWithWindow:window];
[controller setDelegate:self];
// make the window the front window
[window makeKeyAndOrderFront:self];
}
//...
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
NSLog(@"viewWillDisappear called");
}
//...
@end
UPDATE
NSWindowControllerDelegate was added to the class declaration.
@interface BlueController : NSWindowController
However, now I can't figure out how to set the delegate to self.
[self setDelegate:self]; //??
A:
It's because you are using an old way of communicating with a view controller. NSWindowController is a lot more capable than NSViewController, but it is also more disconnected from Cocoa.
Take a look at the new View Controller Programming Guide, and read the "Common Style Guidelines" section. The current View Controller programming style encourages you to separate data from presentation. Cocoa is a framework of objects and bindings, not views. View controllers are used for the presentation layer, and should be very lightweight in the data and logic layers.
A:
viewWillDisappear is called if a view controller's view is removed by the system, such as if the user uses the "Hide" button in the top-right corner ac619d1d87
Related links:
Comments