<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.0.0 - 10.4.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSDocumentController/makeDocumentWithContentsOfFile:ofType:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDocumentController(im)makeDocumentWithContentsOfFile:ofType:"
  },
  "title" : "makeDocumentWithContentsOfFile:ofType:"
}
-->

# makeDocumentWithContentsOfFile:ofType:

Creates and returns a document object of a given document type from the contents of a file.

```
- (id) makeDocumentWithContentsOfFile:(NSString *) fileName ofType:(NSString *) type;
```

## Discussion

Creates and returns an `NSDocument` object for document type `docType` from the contents of the file `fileName`, which must be a fully qualified path. The returned object is not retained. Returns `nil` if the `NSDocument` subclass for `docType` couldn’t be determined or if the object couldn’t be created. This method calls the `NSDocument` method [`initWithContentsOfFile:ofType:`](/documentation/AppKit/NSDocument/initWithContentsOfFile:ofType:) and is called by [`openDocumentWithContentsOfFile:display:`](/documentation/AppKit/NSDocumentController/openDocumentWithContentsOfFile:display:).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)