<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSDocument/init()",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDocument(im)init"
  },
  "title" : "init()"
}
-->

# init()

Initializes and returns an empty document object.

```
init()
```

## Return Value

An initialized `NSDocument` object.

## Discussion

This initializer (the designated initializer) is invoked by each of the other `NSDocument` initialization methods.

You can override this method to perform initialization that must be done both when creating new empty documents and when opening existing documents. Your override must invoke `super` to initialize private `NSDocument` instance variables. It must never return `nil`. If an error can occur during object initialization, check for the error in an override of [`init(type:)`](/documentation/AppKit/NSDocument/init(type:)), [`init(contentsOf:ofType:)`](/documentation/AppKit/NSDocument/init(contentsOf:ofType:)), or [`init(for:withContentsOf:ofType:)`](/documentation/AppKit/NSDocument/init(for:withContentsOf:ofType:)), because those methods can return `NSError` objects.

## See Also

[Developing a Document-Based App](/documentation/AppKit/developing-a-document-based-app)

Write an app that creates, manages, edits, and saves text documents.



---

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)