I have a direct, Mac OS X, Cocoa, document-based application that uses the new APIs 10.7 Autosave, Versions and Asychronous Saving. I make full use of the NSDocument
to get all the features of an Apple Document-based application for free.
To support the new Lion Autosave / Versions / AsyncSaving, I overridden the following methods in my NSDocument
subclass, for example:
@implementation MyDocument ... + (BOOL)autosavesInPlace { return YES; } - (BOOL)canAsynchronouslyWriteToURL:(NSURL *)URL ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)op { return YES; }
I also overridden -dataOfType:error:
to help implement saving the document data to disk:
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outErr { NSData *data = nil; if ([typeName isEqualToString:MY_SUPPORTED_TYPE_NAME]) { data = makeSnapshotCopyOfMyDocumentData(); // assume return value is autoreleased } else if (outErr) { *outErr = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:nil]; } // not sure this is doing much good, since i take no action after this. [self unblockUserInteraction]; return data; } ... @end
See what I call -unblockUserInteraction
at the end?
With support for the new 10.7 feature, AsyncSaving Apple recommends calling -unblockUserInteraction
as soon as possible (after creating a copy of your snapshot data) in your implementation -dataOfType:error:
But Apple's example showed that they do a lot more work after calling -unblockUserInteraction
.
However, given that after that I do not take any other action, I wonder if there is anything at all to call -unblockUserInteraction
.
So my questions are:
Given that after that I take no other action, is my call to -unblockUserInteraction
useful?
Is the Apple Framework just calling -unblockUserInteraction
right after -dataOfType:error:
returned anyway? Should I just leave them to them?
source share