Instance Method

loadDataRepresentation:ofType:

Overridden by subclasses to load document data.

Declaration

- (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: 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: or 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:

//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;
}

See Also

Deprecated Methods

- canCloseDocument

This method is no longer supported.

- dataRepresentationOfType:

A primitive method overridden by subclasses to return a data object that represents the data of the receiver in a given type.

Deprecated
- fileAttributesToWriteToFile:ofType:saveOperation:

Returns the file attributes that should be written to the named document file of the specified type.

Deprecated
- fileName

Returns the filename (as a fully qualified path) under which the receiver has been saved.

Deprecated
- fileNameFromRunningSavePanelForSaveOperation:

Returns the filename entered into the Save panel.

- fileWrapperRepresentationOfType:

Returns an NSFileWrapper object that represents the data of the receiver in a given type.

Deprecated
- initWithContentsOfFile:ofType:

Initializes and returns an NSDocument object.

Deprecated
- initWithContentsOfURL:ofType:

Initializes and returns an NSDocument object of a given document type.

Deprecated
- loadFileWrapperRepresentation:ofType:

Loads document data from a given file wrapper.

Deprecated
- printShowingPrintPanel:

Overridden by subclasses to print the current document’s (the receiver’s) data.

Deprecated
- readFromFile:ofType:

Reads and loads document data of the given type from the given file.

Deprecated
- readFromURL:ofType:

Reads and loads document data.

Deprecated
- revertToSavedFromFile:ofType:

Reverts the receiver to the data stored in the file system.

Deprecated
- revertToSavedFromURL:ofType:

Reverts the receiver.

Deprecated
- runModalPageLayoutWithPrintInfo:

Runs the page layout modal panel with the receiver’s printing information object.

Deprecated
- saveToFile:saveOperation:delegate:didSaveSelector:contextInfo:

Called after the user has been given the opportunity to select a destination through the modal Save panel.

Deprecated
- saveToURL:ofType:forSaveOperation:error:

Saves the contents of the document to a file or file package located by a URL, formatted to a specified type, for a particular kind of save operation, and returns YES if successful.

Deprecated
- setFileName:

Sets the file (filename and directory path) under which document data is saved.

Deprecated
- shouldCloseWindowController:

Gives the user an opportunity to save the document.

- validateMenuItem:

Validates the Revert menu item and items selected from the Save panel’s pop-up list of writable document types items.

- writeToFile:ofType:

Writes document data to a file.

Deprecated
- writeToFile:ofType:originalFile:saveOperation:

Writes the receiver document’s contents to a file.

Deprecated
- writeToURL:ofType:

Writes document data to a URL.

Deprecated
- writeWithBackupToFile:ofType:saveOperation:

This method is called by action methods to save document contents to a file.

Deprecated