Instance Method


Initializes a document of a specified type.


- (instancetype)initWithType:(NSString *)typeName error:(NSError * _Nullable *)outError;



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


- init

Initializes and returns an empty NSDocument object.

- initWithContentsOfURL:ofType:error:

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

- initForURL:withContentsOfURL:ofType:error:

Initializes a document located by a URL of a specified type, but by reading the contents for the document from a different URL.