I am trying to open a managed document using openWithCompletionHandler:
The problem I am coming across is that it works fine on the simulator, but when I test it on my iPhone 4 the completion handler never finishes. The code looks like this:
[theManagedDocument openWithCompletionHandler:^(BOOL success){
if(success) [self documentIsReady];
if(!success) NSLog(@"Couldn't Open Document");
}];
This works fine on the simulator and I get to the documentIsReady
call (or the "Couldn't Open Document" if it errors). But on the iPhone 4 it never runs the CompletionHandler block. I've put breakpoints all through the block (before and after both if statements) and nothing is getting called. No "Couldn't Open Document" on the console, no call to documentIsReady
.
I must also mention that it seems like the first time I run the app on the iPhone it will work properly. I also have this encapsulated in an if statement with a fileExistsAtPath:
call. It is getting inside the if statement just fine and calling the openWithCompletionHandler:
, but the completion block just never gets fired.
I am using iOS 5.1 and Xcode 4.3.2.
In my case, powering off my iPad and restarting it "fixed" this problem. Good luck!