How do I implement loading and saving when the simple data or file wrapper API won’t do?
If, for some reason, neither the NSData nor the NSFileWrapper loading and saving API work for you, you can override the three NSDocument methods that load and save a document from a URL. These methods are: • readFromURL:ofType:error: • writeToURL:ofType:error: • writeToURL:ofType:forSaveOperation:originalContentsURL:error: You should override the reading method and one of the writing methods if you are going to use these as your only reading and writing methods. You might also override these methods not to provide the loading and saving behavior, but rather to do something immediately before or after actually loading or saving. In this case you would add your code before or after a call to the superclass implementation. This type of overriding is discussed in “How can I support reading one type and automatically converting (internally) to another?.