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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:08:57+00:00 2026-05-15T14:08:57+00:00

I have a custom view controller that implements the from UITableViewDataSource and UITableViewDelegate protocols.

  • 0

I have a custom view controller that implements the from UITableViewDataSource and UITableViewDelegate protocols. When I load data for my table (in my viewDidLoad method), I create a NSOperationQueue and a NSInvocationOperation and add it to the queue. I throw up an activity indicator, and viewDidLoad exits.

The method used for the operation ends the activity indicator animation.

I have noticed that when the operation completes, there is a 5-7 second pause before the operation really completes, even though by NSLog it looks like the operation’s method returned.

I have tried to use Instruments to figure out where the pause is happening, but I can’t tell from it because most of my CPU time is spent in system libraries.

Edit
Here’s an abbreviated version:

@implementation MyViewController
@synthesize ...

- (void)viewDidLoad {
    [super viewDidLoad];
    self.opsQueue = [[NSOperationQueue alloc] init];

    NSInvocationOperation *aiStartOp = [[[NSInvocationOperation alloc]
                                           initWithTarget:self
                                                 selector:@selector(showActivityIndicators)
                                                   object:nil] autorelease];
    [self.opsQueue addOperation:aiStartOp];

    NSInvocationOperation *dataOp = [[[[NSInvicationOperation alloc] 
                                         initWithTarget:self
                                               selector:@selector(dataUpdate)
                                                 object:nil] autorelease];
    [dataOp addDependency aiStartOp];
    [self.opsQueue addOperation:dataOp];

    NSInvicationOperation *aiStopOp = [[[NSInvicationOperation alloc]
                                          initWithTarget:self
                                                selector:@selector(hideActivityIndicators)
                                                  object:nil] autorelease];
    [aiStopOp addDependency:dataOp];
    [self.opsQueue addOperation:aiStopOp];
}

/* other stuff */

@end

Just to be clear, the last operation in the queue is this:

- (void)hideActivityIndicators {
    DLog(@"hiding activity indicator");
    self.portraitChartProgressView.hidden = YES;
    [self.portraitChartProgressIndicator stopAnimating];

    self.landscapeProgressView.hidden = NO;
    [self.landscapeProgressIndicator startAnimating];
}

What I see in the log is the output of the above log message, followed by a pause of 5 seconds, and then finally followed by the view with the indicator on it being hidden.

Any ideas?

  • 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-05-15T14:08:58+00:00Added an answer on May 15, 2026 at 2:08 pm

    All UI events, drawing etc. need to be performed on the main thread.
    You can forward calls to the main thread using something like the following.

    - (void)hideActivityIndicators {
    
        if (![NSThread isMainThread]) 
             [self performSelectorOnMainThread:@selector(hideActivityIndicators) withObject:nil waitUntilDone:NO];
    
        DLog(@"hiding activity indicator");
        self.portraitChartProgressView.hidden = YES;
        [self.portraitChartProgressIndicator stopAnimating];
    
        self.landscapeProgressView.hidden = NO;
        [self.landscapeProgressIndicator startAnimating];
    }
    

    EDIT”

    Now that I look a little more carefully, one thing you probably don’t need to do is start and stop the “loading” views by adding to an NSOperationQueue. Likely the only thing that you need to do in in the queue is the data update, then post notifications and delegation to update your views when the data operation is complete.

    The TopSongs sample project demonstrates this very well. The forwarding statement to the main thread is based on code in the AppDelegate.m file in the sample.

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

Sidebar

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Remove the OFFSET 1 at the end of the query… May 16, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer Use GetCurrentDirectory() Directory.GetCurrentDirectory(); May 16, 2026 at 4:26 pm
  • Editorial Team
    Editorial Team added an answer Handlers are used for updating the UI from other (non-UI)… May 16, 2026 at 4:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

This is a weird issue. I have created a view controller with a nib
I've currently got a BaseController class that inherits from System.Web.Mvc.Controller . On that class
I have an iPhone application which basically is getting information from an API (in
In my iPhone app I have a UIViewController that has a UITableView and another
I have an TabBar app that I would like to be in landscape and
I have a subclass of UITabBarController which i am using so that i can
I have a custom UIButton with a png inside it. I have quite a
I have an UIViewController subclass that allows the user to add a new model
I have a UITabbar with multiple view controllers. One of them is a UITableView.
I have a UINavigationController with 3 levels of hierarchy: Menu->Submenu->Details. Menu and Submenu are

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.