Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I finally figured out my problem, thanks to @Eimantas for his help. He was right about overloaded queue. Since "saveToUrl:forSaveOperation:completionHandler:" is i/o operation, queue created a lot of threads (for each UIDocument) and app hangs.</p> <p>I overloaded "saveToUrl:forSaveOperation:completionHandler:" method in my custom UIDocument (to avoid saving docs in concurrent threads):</p> <pre><code>- (void)saveToURL:(NSURL *)url forSaveOperation:(UIDocumentSaveOperation)saveOperation completionHandler:(void (^)(BOOL))completionHandler { NSError *contentsError = nil; NSError *attributesError = nil; NSError *savingError = nil; [self writeContents:[self contentsForType:self.fileType error:&amp;contentsError] andAttributes:[self fileAttributesToWriteToURL:url forSaveOperation:saveOperation error:&amp;attributesError] safelyToURL:url forSaveOperation:saveOperation error:&amp;savingError]; NSLog(@"SAVING ERRORS: contents error - %@, attributes error - %@, saving error - %@",[contentsError localizedDescription], [attributesError localizedDescription], [savingError localizedDescription]); } </code></pre> <p>Then I used my own serial queue to execute all save operations. At first, you need to add it like an iVar:</p> <pre><code>dispatch_queue_t mySerialQueue; </code></pre> <p>Then create it in init method:</p> <pre><code>myCustomQueue = dispatch_queue_create("com.whatever.MyAwesomeQueue", DISPATCH_QUEUE_SERIAL); </code></pre> <p>use it for saving:</p> <pre><code>dispatch_async(mySyncQueue, ^{ // do saving stuff }); </code></pre> <p>and then release it in dealloc:</p> <pre><code>dispatch_release(mySyncQueue); </code></pre> <p>After this changes I don't have any problems with it.</p> <p>Hope this helps! (and sorry for my English :>)</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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