Skip to content

Commit ce89c75

Browse files
Doc improvments
1 parent ec273e0 commit ce89c75

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies: [
1919

2020
**ContainedDocumentController**
2121

22-
An `NSDocumentController` subclass that manages the `NSDocument` lifecycle and manages the relationship to your containers. To use it, you must override the three container-document association methods. Restorable state is supported, but is optional.
22+
An `NSDocumentController` subclass that manages the `NSDocument` life-cycle and relationship to your containers. To use it, you must override the three container-document association methods. Restorable state is supported, but is optional.
2323

2424
```swift
2525
open func associateDocument(_ document: NSDocument, to container: Container)
@@ -31,6 +31,8 @@ open func restoreState(with coder: NSCoder, for document: NSDocument)
3131
// ...
3232
```
3333

34+
Also, don't forget that an `NSDocumentController` is global to your AppKit process. You must instantiate your subclass as soon as possible to ensure it is being used.
35+
3436
**ContainedDocument**
3537

3638
This is an `NSDocument` subclass that makes it possible to support document duplication and window restoration.

Sources/ContainedDocument/ContainedDocumentController.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,26 @@ open class ContainedDocumentController<Container>: BaseDocumentController {
5555

5656
/// Called when a document is being associated to a container
5757
///
58-
/// The default implemenation does nothing. Subclasses can use this to establish
58+
/// The default implementation does nothing. Subclasses can use this to establish
5959
/// a relationship, if it is appropriate for the document/container type.
6060
open func associateDocument(_ document: NSDocument, to container: Container) {
61+
print("warning: associateDocument not implemented in subclass")
6162
}
6263

6364
/// Called when a document is being removed.
6465
///
65-
/// The default implemenation does nothing. Subclasses can use this to tear down
66+
/// The default implementation does nothing. Subclasses can use this to tear down
6667
/// a relationship, if it is appropriate for the document/container type.
6768
open func disassociateDocument(_ document: NSDocument) {
69+
print("warning: disassociateDocument not implemented in subclass")
6870
}
6971

7072
/// Used to query the current container of a document.
7173
///
72-
/// The default implemenation returns nil.
74+
/// The default implementation returns nil.
7375
open func documentContainer(for document: NSDocument) -> Container? {
76+
print("warning: documentContainer not implemented in subclass")
77+
7478
return nil
7579
}
7680

0 commit comments

Comments
 (0)