I have an application which I use a third party library for saving and loading data. Normally when using NSDocument, I have override the - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
method and return the proper data, but with this library I only have access to a save routine (which could also create multiple files, otherwise I would save to a temporary file and return the data of the temporary file).
I also tried the following:
- (void)saveToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation completionHandler:(void (^)(NSError *errorOrNil))completionHandler
{
librarySaveFunction(url.path);
}
Which works, but the documents title stays as 'MyFile - Edited', and if I try to save again, I get an error that the document has been updated by another application (I was able to resolve this by setting my file modification date, but the file is still marked as Edited and it feels very hackish).
Does anyone have a better suggestion on a better way to override the saving routine?