Note that there are some explanatory texts on larger screens.

plurals
  1. POUIDocument closeWithCompletionHandler: completes immediately
    primarykey
    data
    text
    <p>Documentation of <code>closeWithCompletionHandler"</code> says: "After the save operation concludes, the code in completionHandler is executed." However, in my app this code:</p> <pre><code>NSLog(@"closeWithCompletionHandler"); [self.document closeWithCompletionHandler:^(BOOL success) { if (success) { NSLog(@"completionHandler"); ... </code></pre> <p>executes immediately (on iOS6.1):</p> <pre><code>2013-07-18 19:43:12.673 FooBar[819:907] closeWithCompletionHandler 2013-07-18 19:43:12.675 FooBar[819:907] completionHandler &lt;-- look here 2013-07-18 19:43:16.234 FooBar[819:907] encoded </code></pre> <p>even though actual writing data to a file takes several seconds (I know that by tracking <code>contentsForType:error:</code>).</p> <p><code>contentsForType:error:</code> implementation looks like this:</p> <pre><code>- (id)contentsForType:(NSString *)typeName error:(NSError *__autoreleasing *)outError { NSMutableDictionary* wrappers = [NSMutableDictionary dictionary]; [self encodeObject:self.data toWrappers:wrappers preferredFilename:kDocumentDataPath]; NSFileWrapper* fileWrapper = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:wrappers]; NSLog("encoded"); return fileWrapper; } </code></pre> <p>Please note encoding finishing long after completionHandler executes:</p> <pre><code>2013-07-18 19:43:12.675 FooBar[819:907] completionHandler 2013-07-18 19:43:16.234 FooBar[819:907] encoded &lt;-- look here </code></pre> <p>Why is this so? How should I make sure that data is written out to file before proceeding?</p>
    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