Skip to content
An easy-to-use singleton which manages `NSWindow` and `NSWindowController` objects
Objective-C
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CBHWindowManager.xcodeproj
CBHWindowManager
CBHWindowManagerTests
.gitattributes
.gitignore
CBHWindowManager.podspec
LICENSE
README.md

README.md

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.

You can’t perform that action at this time.