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

# loadDataRepresentation:ofType:

Loads the document data.

```
- (BOOL) loadDataRepresentation:(NSData *) data ofType:(NSString *) type;
```

## Discussion

Overridden by subclasses to load document data (`docData`) of type `docType` into the receiver, display it in windows, and return whether the operation was successful. This method is typically invoked by [`loadFileWrapperRepresentation:ofType:`](/documentation/AppKit/NSDocument/loadFileWrapperRepresentation:ofType:) after an `NSData` object is created from the contents of the file wrapper (which can include directories). The default implementation `raises` an `NSInternalInconsistencyException`. Subclasses must override this method unless they override [`readFromFile:ofType:`](/documentation/AppKit/NSDocument/readFromFile:ofType:) or [`loadFileWrapperRepresentation:ofType:`](/documentation/AppKit/NSDocument/loadFileWrapperRepresentation:ofType:) to do specialized reading and loading of document data.

The `docType` argument is the type name corresponding to the value of the `CFBundleTypeName` entry in the document type’s `Info.plist` dictionary.

Here is an example implementation:

```objc
//Document type name
NSString *MyDocumentType = @"Rich Text Format (RTF) document";
 
...
 
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType  {
    NSAssert([aType isEqualToString: MyDocumentType], @"Unknown  type");
    fileContents = [data copyWithZone:[self zone]];
    return YES;
}
```

---

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)