Instance Method

initWithType:error:

Initializes a document of a specified type.

Declaration

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

Parameters

typeName

The string that identifies the document type.

outError

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.

Discussion

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

- init

Initializes and returns an empty document object.

- initWithContentsOfURL:ofType:error:

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

- initForURL:withContentsOfURL:ofType:error:

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