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 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

Related Questions

I have a segue (called ToSettingsSegue ) that pushes a custom view controller (
In a word, how? I have a view controller that creates a few custom
I have a table view controller with custom cells. In those cells i added
If I have a custom view controller class that I want to reuse but
I have to pop to HomeScreenViewController from current view controller after clicking on custom
I have an app with a custom UITabBarController that contains five view controllers. Within
I have a custom View that I would like to embed in an WebView.
I have implemented a custom split view controller which — in principle — works
In my custom View which I have added to my viewControllers's view, I need
I have a custom view which has a piano keyboard drawn inside of it.

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.