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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:17:06+00:00 2026-06-06T08:17:06+00:00

In Grand Central Dispatch I want to start a spinner – UIActivityIndicatorView – spinning

  • 0

In Grand Central Dispatch I want to start a spinner – UIActivityIndicatorView – spinning prior to beginning long running task:

dispatch_async(cloudQueue, ^{

    dispatch_async(dispatch_get_main_queue(),
            ^{
                [self spinnerSpin:YES];
            });

    [self performLongRunningTask];

    dispatch_async(dispatch_get_main_queue(),
            ^{
                [self spinnerSpin:NO];
             });


});

Here is the spinnerSpin method:

- (void)spinnerSpin:(BOOL)spin {

    ALog(@"spinner %@", (YES == spin) ? @"spin" : @"stop");

    if (spin == [self.spinner isAnimating]) return;

    if (YES == spin) {

        self.hidden = NO;
        [self.spinner startAnimating];
    } else {

        [self.spinner stopAnimating];
        self.hidden = YES;
    }

}

One thing I have never seen discussed is the difference – if any – between [myView setNeedsDisplay] and [myActivityIndicatorView startAnimating]. Do they behave the same?

Thanks,
Doug

  • 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-06T08:17:07+00:00Added an answer on June 6, 2026 at 8:17 am

    The [UIView setNeedsDisplay] method has nothing to do with a UIActivityIndicatorView‘s animation state.

    setNeedsDisplay simply informs the system that this view’s state has changed in a way that invalidates its currently drawn representation. In other words, it asks the system to invoke that view’s drawRect method on the next drawing cycle.

    You very rarely need to invoke setNeedsDisplay from outside of a view, from code that is consuming the view. This method is meant to be invoked by the view’s internal logic code, whenever something changes in its internal state that requires a redraw of the view.

    The [UIActivityIndicatorView startAnimating] method is specific to the UIActivityIndicatorView class and simply asks the indicator to start animating (e.g. spinning). This method is instant, without requiring you to call any other method.

    On a side note, you could simplify your code by simply calling startAnimating or stopAnimating without manually showing/hiding it. The UIActivityIndicatorView class has a hidesWhenStopped boolean property that defaults to YES, which means that the spinner will show itself as soon as it starts animating, and hide itself when it stops animating.

    So your spinnerSpin: method could be refactored like this (as long as you haven’t set the hidesWhenStopped property to NO):

    - (void)spinnerSpin:(BOOL)spin {
        if (YES == spin) {
            [self.spinner startAnimating];
        } else {
            [self.spinner stopAnimating];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Grand Central Dispatch to queue a task to capture a UIView
Apple introduced Grand Central Dispatch (a thread pool) in Snow Leopard, but haven't gone
Does the Grand Central Dispatch API allow an execution context (thread) to query any
I use Grand Central Dispatch methods to do some executions of my app in
Anybody have any thoughts on Grand Central Dispatch (which has now been open-sourced by
How do I get blocks/grand central dispatch working in Snow Leopard? It appears that
Apple's Grand Central Dispatch (GCD) is great, but only works on iOS 4.0 or
I just want to prerender different images for fast access. I use grand central
With Grand Central Dispatch, you can schedule reads and write without needing to worry
I am making heavy use of Grand Central Dispatch. I now have the need

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.