I'm trying to load an UIDocument for a quick preview of its contents (which are wrapped up in a file wrapper). I call this code:
-(void)previewLoadDocAtURL:(NSURL*)fileURL {
NSLog(@"... loading for preview: %@", [fileURL lastPathComponent]);
FRNBDocument *doc = [[FRNBDocument alloc] initWithFileURL:fileURL];
[doc openWithCompletionHandler:^(BOOL success) {
NSLog(@"... loaded for preview: %@", [doc.fileURL lastPathComponent]);
The problem is that it sometimes takes 40 seconds until I get the log and at other times it only takes a couple of milli seconds. Here are the 40 seconds:
2012-06-27 13:58:31.612 Meernotes[4444:11303] ... loading for preview: NOTEBOOK-C759AD40-E6DE-4241-9E5A-22C458BEF8DA.MBOOK
2012-06-27 13:59:11.870 Meernotes[4444:11303] ... loaded for preview: NOTEBOOK-C759AD40-E6DE-4241-9E5A-22C458BEF8DA.MBOOK
Here are the couple of milliseconds:
2012-06-27 14:02:50.829 Meernotes[4510:11303] ... loading for preview: NOTEBOOK-C759AD40-E6DE-4241-9E5A-22C458BEF8DA.MBOOK
2012-06-27 14:02:50.896 Meernotes[4510:11303] ... loaded for preview: NOTEBOOK-C759AD40-E6DE-4241-9E5A-22C458BEF8DA.MBOOK
Why is this so and how can I prevent that it takes 40 seconds?
EDIT
I did more testing. It turns out that this ONLY happens in the simulator when loading local files. The funny thing is that I start the simulator and it takes 40 sec. Then I start the simulator again, it takes milliseconds. Then I start simulator again and it takes 40 sec. etc. So this actually looks like a bug. I'm using the latest xCode 4.5 DP2, so I guess time to file a bug.