Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bug in iPhone Simulator 5.1 with Xcode 4.5 using UIManagedDocument

I have a very weird problem I've spent the last two days trying to solve... I had a piece of code that was working perfectly fine on Xcode 4.4 and iOS 5.1 Simulator, using the 5.1 SDK. After I updated to Xcode 4.5 and the 6.0 SDK, my code stopped working in the iOS 5.1 Simulator... even though it works perfectly fine in the iOS 6.0 Simulator. Was there any change I'm not aware of?

This is the code:

- (void)useDocument
{
    if (![[NSFileManager defaultManager] fileExistsAtPath:[self.database.fileURL path]]){
        [self.database saveToURL:self.database.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success){
            [self setupFetchedResultsController];
    }];
    } else if (self.database.documentState == UIDocumentStateClosed){
        [self.database openWithCompletionHandler:^(BOOL success){
            [self setupFetchedResultsController];
        }];          
    } else if (self.database.documentState == UIDocumentStateNormal) {
        [self setupFetchedResultsController];
    }
}

For some reason saveToURL and openWithCompletionHandler never return in the 5.1 Simulator. Any one knows why?

like image 968
Breno Gazzola Avatar asked Sep 24 '12 00:09

Breno Gazzola


2 Answers

I have the same problem under iPhone Simulator 5.1. The file is created after a long time (30 seconds). But the completion handler is never called. Did you try it on a device?

EDIT: This seems a bug in iOS Simulator 5.1. I compiled the code on my old iPad with iOS 5.1.1 and it worked without an error!

like image 112
FrankZp Avatar answered Oct 21 '22 03:10

FrankZp


Can't say for your project, but here it definitely was Xcode 4.5.

I have a copy of Xcode 4.3.1 with Simulator 5.1 on a virtual machine, and guess what: that one works flawlessly

-> Xcode4.3.1/Simulator5.1 works!

-> Xcode4.5 /Simulator5.1 is faulty

-> Xcode4.5.1/Simulator5.1 is faulty

As a workaround you can download version 5.0 of the simulator in Xcode -> Preferences -> Downloads. That one works.

like image 27
brainray Avatar answered Oct 21 '22 05:10

brainray