CBHWindowManager 1.0.2

CBHWindowManager 1.0.2

Maintained by Chris Huxtable.



CBHWindowManager

release pod licence coverage

An easy-to-use singleton which manages NSWindow and NSWindowController objects.

Examples:

Adding a controller so that once the window is closed both the window and controller are released.

SomeWindowController *controller = [[[SomeWindowController class] alloc] initWithWindowNibName:@"SomeWindowNibName"];
[[CBHWindowManager sharedManager] manageController:controller];

Adding a controller with a key so that it may be found by name.

/// Create and adding the controller withe key.
SomeWindowController *controller = [[[SomeWindowController class] alloc] initWithWindowNibName:@"SomeWindowNibName"];
[[CBHWindowManager sharedManager] manageController:controller withKey:@"SomeWindowKey"];

// ...

/// Lookup the controller
SomeWindowController *controller = [[CBHWindowManager sharedManager] controllerForKey:@"SomeWindowKey"];

Finding a controller with a key and if not creating and adding one.

/// Lookup the controller in the manager. If it's found, return early.
SomeWindowController *controller = (SomeWindowController *)[[CBHWindowManager sharedManager] controllerForKey:@"SomeWindowKey"];
if ( controller ) { return controller; }

/// If the controller is not in the manager create it and add it to the manger.
controller = [[[SomeWindowController class] alloc] initWithWindowNibName:@"SomeWindowNibName"];
[[CBHWindowManager sharedManager] manageController:controller withKey:@"SomeWindowKey"];
return controller;

Licence

CBHWindowManager is available under the ISC license.