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 8060925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:09:27+00:00 2026-06-05T10:09:27+00:00

I’m having some issues with my code and not sure how to speed things

  • 0

I’m having some issues with my code and not sure how to speed things up. Here is my code from app delegate (didFinishLaunchingWithOptions method body):

initialized = [[NSUserDefaults standardUserDefaults] boolForKey:@"initialized"];

if (!initialized) {
     dispatch_queue_t queue = dispatch_get_global_queue(
                                                       DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);


    dispatch_async(queue, ^{
        [DAO setDocumentsCacheDirectory:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]];

        ....download images and files needed by application

        NSLog(@"%@", @"Finished downloadding images and files");

        [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshView" object:nil];
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"initialized"];
    });
}

While this asynchronous download is happening I have spinning gif image in my view. As you can see when all this download is done the refreshView method is triggered in my view controller.

After load has finished re-loading I have NSLog(@”%@”, @”Finished reloading..”); so I know when the view has re-loaded.

The problem :

So I’m looking at the console :

2012-06-07 12:52:34.898 TestApp[29800:13c03] Finished downloadding images and files
[Switching to process 29800 thread 0x13c03]
2012-06-07 12:52:34.909 TestApp[29800:13c03] Finished reloading..

File download appears to be done within second or two. Then immediately after as you can see by the timestamp the view reload finishes.

But thing is application waits for 5 seconds or so and I have no idea where and what is going on and only then the view re-refreshes although the message finished reloading.. was displayed about 5 seconds ago.

What would you do next?

  • 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-05T10:09:29+00:00Added an answer on June 5, 2026 at 10:09 am

    You’re posting the notification in the background queue – if this is what triggers the UI update then this needs to be done on the main queue:

    dispatch_async(queue, ^{
        [DAO setDocumentsCacheDirectory:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]];
    
        ....download images and files needed by application
    
        NSLog(@"%@", @"Finished downloadding images and files");
    
        dispatch_sync(dispatch_get_main_queue(), ^{
            [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshView" object:nil];
        }
    
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"initialized"];
    });
    

    Notice I’ve used dispatch_sync here… the NSUserDefaults won’t be updated until the main queue block completes.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

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.