File->Save コマンドを使用して正常に保存できる NSDocument サブクラスがあります。
アプリケーションが特定の操作を実行すると、このファイルが更新され、更新されたファイルをディスクに自動的に保存する必要があります。私は次のすべてを試しました:
//Attempt #1. No error but document in not saved to disk.
NSError * theError;
[myDocument invalidateRestorableState]; //mark document as dirty
[myDocument writeSafelyToURL:[myDocument fileURL] ofType:CONSTANT_CONTAINING_FILE_EXTENSION forSaveOperation:NSAutosaveInPlaceOperation error:&theError];
if (theError != nil)
[NSApp presentError:theError];
//Attempt #2. Completion handler is not called. Doc is not saved to disk.
[myDocument saveToURL:[myDocument fileURL] ofType:CONSTANT_CONTAINING_FILE_EXTENSION forSaveOperation:NSAutosaveInPlaceOperation completionHandler:^(NSError *errorOrNil) {
if (errorOrNil != nil)
[NSApp presentError:errorOrNil];
}];
//Attempt #3. No error but doc is not saved to disk.
NSError * theError;
[myDocument saveToURL:[myDocument fileURL] ofType:CONSTANT_CONTAINING_FILE_EXTENSION forSaveOperation:NSSaveOperation error:&theError];
if (theError != nil)
[NSApp presentError:theError];
//Attempt #4. didSaveDocument is not called. Doc is not saved to disk.
[myDocument saveDocumentWithDelegate:myDocument didSaveSelector:@selector(didSaveDocument:didSave:contextInfo:) contextInfo:nil];
myDocument が存在し、これらの呼び出しが行われた時点で更新されたデータが含まれています。
私は何が欠けていますか?
情報をお寄せいただきありがとうございます。