Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen NSDocument Asynchronous Saving is enabled, is there any point in calling -unblockUserInteraction in a simple -dataOfType:error:?
    primarykey
    data
    text
    <p>I have a straight-forward, Mac OS X, Cocoa, Document-based application which uses the new 10.7 Autosave, Versions and Asychronous Saving APIs. I am fully using the <code>NSDocument</code> APIs to get all of Apple's Document-based application features for free.</p> <p>In order to support the new Lion Autosave/Versions/AsyncSaving, I have overridden the following methods in my <code>NSDocument</code> subclass like so:</p> <pre><code>@implementation MyDocument ... + (BOOL)autosavesInPlace { return YES; } - (BOOL)canAsynchronouslyWriteToURL:(NSURL *)URL ofType:(NSString *)type forSaveOperation:(NSSaveOperationType)op { return YES; } </code></pre> <p>I have also overridden <code>-dataOfType:error:</code> to help implement saving the document's data to disk:</p> <pre><code>- (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 </code></pre> <p>See how I'm calling <code>-unblockUserInteraction</code> at the end there?</p> <p>When supporting the new 10.7 AsyncSaving feature, Apple advises calling <code>-unblockUserInteraction</code> as early as possible (after making a snapshot copy of your document's data) in your <code>-dataOfType:error:</code> implementation. But Apple's example showed them doing much more work after calling <code>-unblockUserInteraction</code>.</p> <p>However, considering I take no other action after this, I'm wondering if there's any point in calling <code>-unblockUserInteraction</code> there at all. </p> <p>So my questions:</p> <ol> <li><p>Considering I take no other action after it, is my call to <code>-unblockUserInteraction</code> doing any good?</p></li> <li><p>Do the Apple Frameworks just call <code>-unblockUserInteraction</code> immediately after <code>-dataOfType:error:</code> returns anyway? Should I just leave it to them?</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload