Initializes a document of a specified type.


convenience init(type typeName: String) throws



The string that identifies the document type.


On return, if initialization is unsuccessful, a pointer to an error object that encapsulates the reason the document could not be created.

Return Value

The initialized NSDocument object, or, if the document could not be created, nil.


The default implementation of this method just invokes [self init] and [self setFileType:typeName].

You can override this method to perform initialization that must be done when creating new documents but should not be done when opening existing documents. Your override should typically invoke super, or at least it must invoke init(), the NSDocument designated initializer, to initialize the NSDocument private instance variables.

See Also

Creating a Document Object


Initializes and returns an empty document object.

init(contentsOf: URL, ofType: String)

Initializes a document located by a URL of a specified type.

init(for: URL?, withContentsOf: URL, ofType: String)

Initializes a document with the specified contents, and places the resulting document's file at the designated location.