11import Cocoa
22
3- class DocumentationWindows : NSObject , NSWindowDelegate {
3+ class DocumentationWindows : NSObject {
44 private var windowControllers : Set < DocumentationWindowController >
55
66 static let shared = DocumentationWindows ( )
@@ -10,11 +10,11 @@ class DocumentationWindows: NSObject, NSWindowDelegate {
1010 }
1111
1212 func newWindow( ) {
13- newWindowFor ( documentation : Documentation . init ( ) )
13+ newWindow ( forDoc : Documentation . init ( ) )
1414 }
1515
16- func newWindowFor ( url: URL ) {
17- newWindowFor ( documentation : Documentation . init ( withURL: url) )
16+ func newWindow ( forURL url: URL ) {
17+ newWindow ( forDoc : Documentation . init ( withURL: url) )
1818 }
1919
2020 func newWindowIfNoWindow( ) {
@@ -23,15 +23,7 @@ class DocumentationWindows: NSObject, NSWindowDelegate {
2323 }
2424 }
2525
26- func windowWillClose( _ notification: Notification ) {
27- guard let window = notification. object as! NSWindow ? else { return }
28- guard let dwc = window. windowController as! DocumentationWindowController ? else {
29- return
30- }
31- windowControllers. remove ( dwc)
32- }
33-
34- private func newWindowFor( documentation: Documentation ) {
26+ private func newWindow( forDoc documentation: Documentation ) {
3527 let dwc = DocumentationWindowController . init ( window: nil )
3628 dwc. documentation = documentation
3729 dwc. window? . delegate = self
@@ -60,11 +52,21 @@ class DocumentationWindows: NSObject, NSWindowDelegate {
6052 return false
6153 }
6254 } . forEach { url in
63- newWindowFor ( url : url)
55+ newWindow ( forURL : url)
6456 }
6557 } else {
6658 newWindow ( )
6759 }
6860 }
61+ }
6962
63+ // MARK:- NSWindowDelegate
64+ extension DocumentationWindows : NSWindowDelegate {
65+ func windowWillClose( _ notification: Notification ) {
66+ guard let window = notification. object as! NSWindow ? else { return }
67+ guard let dwc = window. windowController as! DocumentationWindowController ? else {
68+ return
69+ }
70+ windowControllers. remove ( dwc)
71+ }
7072}
0 commit comments