Contents

writeWithBackupToFile:ofType:saveOperation:

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

Declaration

- (BOOL) writeWithBackupToFile:(NSString *) fullDocumentPath ofType:(NSString *) documentTypeName saveOperation:(NSSaveOperationType) saveOperationType;

Discussion

This method is called by action methods like save(_:), saveAs(_:), and saveTo(_:). It is responsible for handling backup of the existing file, if any, and removal of that backup if keepBackupFile returns false. In between those two things, it calls writeToFile:ofType:originalFile:saveOperation: to write the document of type docType to fullDocumentPath. You should never need to call writeWithBackupToFile:ofType:saveOperation:, but subclasses that want to change the way the backup works can override it. The saveOperationType argument is one of the constants listed in Constants.

If you override this method, you should invoke fileAttributesToWriteToFile:ofType:saveOperation: and set the variables returned from this method when writing fullDocumentPath. NSFileManager setAttributes(_:ofItemAtPath:) can be used to do this.

See Also

Methods