I got an NSDocument
-based app. In the document class, a window is created. This window controller is added in -makeWindowControllers
(code below). If I check out the retain count of my controller ([_windowController retainCount]
) right after adding it, the retain count equals 3. But why? I'd imagine it should be two? What happens in -addWindowController:
?
- (void)makeWindowControllers {
NSLog(@"%li", (unsigned long)[[self windowController] retainCount]); // Outputs 1
[self addWindowController:[self windowController]];
NSLog(@"%li", (unsigned long)[_windowController retainCount]); // Outputs 3
}
- (ProjectWindowController *)windowController {
if (!_windowController) { // Lazy loading
_windowController = [ProjectWindowControllerYosemite new];
}
return _windowController;
}