Cocoa 我不工作了?

Cocoa 我不工作了?,cocoa,nsdocument,Cocoa,Nsdocument,我有一个NSDocument子类,可以使用File->save命令成功保存它 当我的应用程序运行特定操作时,它会更新此文件,并需要自动将更新后的文件保存到磁盘。我尝试了以下所有方法: //Attempt #1. No error but document in not saved to disk. NSError * theError; [myDocument invalidateRestorableState]; //mark document as dirty [myDocument wri

我有一个NSDocument子类,可以使用File->save命令成功保存它

当我的应用程序运行特定操作时,它会更新此文件,并需要自动将更新后的文件保存到磁盘。我尝试了以下所有方法:

//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存在,并包含进行这些调用时更新的数据

我错过了什么


提前非常感谢所有人提供的任何信息

我想我找到了。文件URL错误