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

  • Home
  • SEARCH
  • 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 7956035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:52:25+00:00 2026-06-04T03:52:25+00:00

UIDocument’s saveToURL:forSaveOperation:completionHandler: is suppose to be asynchronous (in documentation, it says it performs this

  • 0

UIDocument’s saveToURL:forSaveOperation:completionHandler: is suppose to be asynchronous (in documentation, it says it performs this action on a background queue), but my code has a 7-10 seconds lag when calling this.

Here’s the code:

NSLog(@"saving image...");
[picDoc saveToURL:[picDoc fileURL] 
 forSaveOperation:UIDocumentSaveForCreating 
completionHandler:^(BOOL success) {


    dispatch_async(dispatch_get_main_queue(), ^{
        if (success) {
            NSLog(@"image save successful!");
            UIImage *thumbnail = [image imageByScalingAndCroppingForSize:CGSizeMake(146, 110)];
            Picture *picture = [[Picture alloc] initWithThumbnail:thumbnail filename:fileName];
            [[set pictures] addObject:picture];




            [self setupPictures];

            [scrollView scrollRectToVisible:((UIView *)[[scrollView subviews] lastObject]).frame animated:YES];
            currentIndex = [[set pictures] count] - 1;
            [self showPicture];

        } else {
            NSLog(@"failed saving image");
        }
        [SVProgressHUD dismiss];
    });

    [picDoc closeWithCompletionHandler:nil];
}];
NSLog(@"exit");

And the console:

2012-05-15 07:07:27.417 Picventory[5939:707] saving image...
2012-05-15 07:07:34.120 Picventory[5939:707] exit
2012-05-15 07:07:34.740 Picventory[5939:707] image save successful!

Why is there such a huge lag when the call is asynchronous?
Thanks

  • 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-04T03:52:26+00:00Added an answer on June 4, 2026 at 3:52 am

    Writing the file to disk is asynchronous, but taking the snapshot of the document’s data is not. You should use the Time Profiler in Instruments to find out what is actually taking so long. I would guess that you might need to optimize your contentsForType:error: (or equivalent) method, but measure first!

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

Sidebar

Related Questions

When this code is executed, the src and alt are set correctly, but border
I have an exception breakpoint set and when I call - (void)saveToURL:(NSURL *)url forSaveOperation:(UIDocumentSaveOperation)saveOperation
When a UIDocument is closed, can it close again? Even when it's documentState is
I setting up UIDocument to save my files to the device. I mark a
I need a relative path in this function: $(function() { $(#searchbox).autocomplete({ minLength : 2,
This is a (to me) pretty weird problem, because it was already running perfectly
Whenever I load a UIDocument from iCloud, I check its state like so: NSLog(@Library
I'm working with the new UIDocument features in iOS 5.0. I have an existing
To support iCloud, we're encouraged to use a UIDocument subclass. If I define a
I'm trying to figure out what exactly the UIDocument subclass should look like when

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.