0

I have an NSDocument subclass that I can save successfully using the File->Save command.

When my application runs a specific operation, it updates this file, and needs to automatically save the updated file to disk. I have tried all the following:

//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 exists and contains the updated data at the time these calls are made.

What am I missing?

Thanks very much in advance to all for any info!

VikR
  • 4,818
  • 8
  • 51
  • 96

1 Answers1

0

I think I found it. The fileURL is wrong.

VikR
  • 4,818
  • 8
  • 51
  • 96