writeToFile:ofType:
Writes document data to a file.
Declaration
- (BOOL) writeToFile:(NSString *) fileName ofType:(NSString *) type;Discussion
Writes document data of type docType to the file fileName, returning whether the operation was successful. This method invokes dataRepresentationOfType: and is indirectly invoked whenever the document file is saved. It uses the NSData method write(toFile:atomically:) to write to the file.
This method is one of the location-based primitives. Subclasses can override this method instead of overriding dataRepresentationOfType: to write document data to the file system as an NSData object after creating that object from internal data structures. Subclasses that handle file packages such as RTFD or that treat locations of files as anything other than paths should override this method. Override implementations of this method should ensure that they filter document data appropriately using NSPasteboard filtering services.
See Document Saving Behavior for additional information about saving documents.
See Also
Methods
dataRepresentationOfType:fileAttributesToWriteToFile:ofType:saveOperation:fileNamefileWrapperRepresentationOfType:initWithContentsOfFile:ofType:initWithContentsOfURL:ofType:loadDataRepresentation:ofType:loadFileWrapperRepresentation:ofType:printShowingPrintPanel:readFromFile:ofType:readFromURL:ofType:revertToSavedFromFile:ofType:revertToSavedFromURL:ofType:runModalPageLayoutWithPrintInfo:saveToFile:saveOperation:delegate:didSaveSelector:contextInfo: