Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8076495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:16:21+00:00 2026-06-05T15:16:21+00:00

I have a project with iCloud sync, but it doesn’t work correctly at all.

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:16:22+00:00Added an answer on June 5, 2026 at 3:16 pm

    I finally figured out my problem, thanks to @Eimantas for his help. He was right about overloaded queue. Since “saveToUrl:forSaveOperation:completionHandler:” is i/o operation, queue created a lot of threads (for each UIDocument) and app hangs.

    I overloaded “saveToUrl:forSaveOperation:completionHandler:” method in my custom UIDocument (to avoid saving docs in concurrent threads):

    - (void)saveToURL:(NSURL *)url forSaveOperation:(UIDocumentSaveOperation)saveOperation completionHandler:(void (^)(BOOL))completionHandler {
    NSError *contentsError = nil;
    NSError *attributesError = nil;
    NSError *savingError = nil;
    
    [self writeContents:[self contentsForType:self.fileType error:&contentsError] andAttributes:[self fileAttributesToWriteToURL:url forSaveOperation:saveOperation error:&attributesError] safelyToURL:url forSaveOperation:saveOperation error:&savingError];
    
    NSLog(@"SAVING ERRORS: contents error - %@, attributes error - %@, saving error - %@",[contentsError localizedDescription],  [attributesError localizedDescription], [savingError localizedDescription]);
    }
    

    Then I used my own serial queue to execute all save operations.
    At first, you need to add it like an iVar:

    dispatch_queue_t mySerialQueue;
    

    Then create it in init method:

    myCustomQueue = dispatch_queue_create("com.whatever.MyAwesomeQueue", DISPATCH_QUEUE_SERIAL);
    

    use it for saving:

    dispatch_async(mySyncQueue, ^{
        // do saving stuff
    });
    

    and then release it in dealloc:

    dispatch_release(mySyncQueue);
    

    After this changes I don’t have any problems with it.

    Hope this helps! (and sorry for my English :>)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that has iCloud enabled in the Entitlements file, but doesn't
If you have Project A and it needs all the dependencies of Project B,
I have project that concerns about calendars, at first i have 1 calendar and
i have project in .net , i want to test it. But i dont
I have project containing few user controls (each represents a game, but that's irrelevant),
In a project at work we have a certain value type class in our
I have project in Django 1.3. In order to show username in all pages
I have project on my computer and I want my colleagues to work with
We have project (PHP application), but instalation for each client vary, sometimes very little,
I want to sync my Core Data shoebox app with iCloud. An example project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.