I have a project with iCloud sync, but it doesn't work correctly at all. At first, I get an array of changed objects, then I convert them to CSV strings (which will be the contents of UIDocuments in cloud) and then I upload them to iCLoud. If I have less than 400 objects, everything is OK, but if I have more - app hangs.
I've tried to use local autorelease pool, I've split up large array to smaller ones. But it didn't help.
What is the best way for uploading a lot of UIDocuments into iCloud? My uploading method:
- (void)pushChangesToCloud:(NSArray *)changedObjects {
for (ObjectClass *someObject in changedObjects) {
NSURL *pathToSyncDoc = [[self urlForDocumentsFolderIniCloud] URLByAppendingPathComponent:someObject.name];
CustomUIDocument *syncDoc = [[[CustomUIDocument alloc] initWithFileURL:pathToSyncDoc] autorelease];
// converting object to CSV string
NSString *csvContents = [SomeClass convertObjectToCSV:someObject];
syncDoc.documentContent = csvContents;
[syncDoc saveToURL:[syncDoc fileURL]
forSaveOperation:UIDocumentSaveForCreating
completionHandler:^(BOOL success) {
if (success) {
NSLog(@"YAY!");
} else {
NSLog(@" D: ");
}
}];
}
}
Thanks in advance and sorry for my English.