makeDocument(withContentsOf:ofType:)
Instantiates a document located by a URL, of a specified type, and returns it if successful.
Declaration
func makeDocument(withContentsOf url: URL, ofType typeName: String) throws -> NSDocumentParameters
- url:
The location of the new document object.
- typeName:
The type of the document.
Return Value
The newly created NSDocument object, or nil if the document could not be created.
Discussion
The URL is specified by absoluteURL and the document type by typeName. If not successful, the method returns nil after setting outError to point to an NSError that encapsulates the reason why the document could not be instantiated. The default implementation of this method calls documentClass(forType:) to find out the class of document to instantiate, allocates a document object, and initializes it by sending it an init(contentsOf:ofType:) message.