2

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.

n.evermind
  • 11,944
  • 19
  • 78
  • 122
  • Did you end up figuring out a fix for this or filing a radar? I am experiencing the same issue and it is quite annoying. – chown Jan 06 '13 at 01:36

1 Answers1

2

Usually iCloud files are downloaded on demand, so If your document is in iCloud and it has never been opened before it will might take a while so depending on your internet connection and file size :)

I've noticed that the very first time iCloud loads something it takes some seconds more than usual.

Lastly, iCloud APIs are sooooo buggy. No wonder why so very few official apps have adopted it in iOS5/OSX10.7. But don't blame Apple too much, after all it is their first iteration :)

nacho4d
  • 43,720
  • 45
  • 157
  • 240
  • Guess you're right. I've updated my question-- which isn't really a question but becomes more of a bug report. – n.evermind Jun 27 '12 at 13:25