Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIDocument save to URL fails?

It seems that completion handler block is never invoked. Is that means the save fails? I po self.document.fileURL in console, which appears valid.

[self.document saveToURL:self.document.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
// set breakpoint here, but it won't stop
            [[[Fetcher alloc]init] fetchImageFromSring:HTTP_REQUEST inContext:self.document.managedObjectContext];
        }];
like image 358
Philip007 Avatar asked Apr 21 '26 22:04

Philip007


1 Answers

The completion handler block should be invoked regardless of whether the save succeeded

About the completionHandler from apple

completionHandler
A block with code that is executed when the save operation concludes. The block returns no value and has one parameter:
success
YES if the save operation succeeds, otherwise NO.
This block is invoked on the calling queue.

Have you put a breakpoint on this line to make sure it runs

[self.document saveToURL:self.document.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {

EDIT
I believe the issue can be which type of debugger you are using. (from this SO question)
Make sure you are using lldb

Even if you don't change debuggers, you could always verify the block is executed with NSLog(@"block is running, save successfully - %d", success)

like image 50
Jesse Black Avatar answered Apr 24 '26 13:04

Jesse Black



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!