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];
}];
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With