1

I have a method called useDocument which runs when the property (a UIDocument subclass called ‘document’) of my view controller gets set. Here’s the method:

- (void)useDocument
{
    if (![[NSFileManager defaultManager] fileExistsAtPath:self.document.fileURL.path]) {
        //
        //  Does not exist on disk, save
        //
        [self.document saveToURL:self.document.fileURL
                forSaveOperation:UIDocumentSaveForCreating
               completionHandler:^(BOOL success) {
                   if (!success) {
                       NSLog(@"Failed to create file at url: %@", self.document.fileURL);
                   } else {
                       NSLog(@"Created file at %@", self.document.fileURL);
                   }


               }];
    } else if (self.document.documentState == UIDocumentStateClosed) {
        //
        //  Document is closed, open
        //
        [self.document openWithCompletionHandler:^(BOOL success) {
            if (!success) {
                NSLog(@"Failed to open file at url: %@", self.document.fileURL);
            } else {
                NSLog(@"Opened file at %@", self.document.fileURL);
            }
        }];
    } else if (self.document.documentState == UIDocumentStateNormal) {
        //
        //  Document is ready to be used
        //
    }
}

The view controller successfully gets pushed on to the stack and shown, but when the file doesn’t exist and has to be saved, there is a noticeable gap (about 11 seconds) between the log which says the file has been saved, and the navigation bar content appearing (a UIBarButtonItem)

I should also point out that the UICollectionView inside the view controller shows itself.

Does anyone know why this might be?

Adam Carter
  • 4,741
  • 5
  • 42
  • 103

1 Answers1

0

Setting it programmatically works, but if anyone has a solution for IB i’d rather hear it!

Adam Carter
  • 4,741
  • 5
  • 42
  • 103