Here is a snippet of relevant code:
NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
url = [url URLByAppendingPathComponent:@"Demo Document"];
UIManagedDocument *document = [[UIManagedDocument alloc] initWithFileURL:url];
if (document.documentState == UIDocumentStateClosed) {
NSLog(@"file is closed");
NSLog(@"%@",[url path]);
NSDate *start = [NSDate date];
[document openWithCompletionHandler:^(BOOL success) {
if (success) {
NSLog(@"finished OPEN");
NSDate *methodFinish = [NSDate date];
NSTimeInterval executionTime = [methodFinish timeIntervalSinceDate:start];
NSLog(@"time = %f",executionTime);
self.managedObjectContext = document.managedObjectContext;
}
}];
}
The time interval between "file is closed" and "finished open" was 16.6 seconds. Is this normal behavior? Bad coding? Or is it because I am running on a simulator?
I don't know if it would matter, but the file is barely 50KB...