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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:04:09+00:00 2026-05-14T03:04:09+00:00

I’m developing an iPhone app that features a tab-bar based navigation with five tabs.

  • 0

I’m developing an iPhone app that features a tab-bar based navigation with five tabs. Each tab contains a UITableView whose data is retrieved remotely. Ideally, I would like to use a single UIActivityIndicatorView (a subview of the window) that is started/stopped during this remote retrieval – once per tab.

Here’s how I set up the spinner in the AppDelegate:

- (void)applicationDidFinishLaunching:(UIApplication *)application {    
  [window addSubview:rootController.view];

  activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
  [activityIndicator setCenter:CGPointMake(160, 200)];
  [window addSubview:activityIndicator];

  [window makeKeyAndVisible];
}

Since my tabs were all performing a similiar function, I created a base class that all of my tabs’ ViewControllers inherit from. Here is the method I’m using to do the remote retrieval:

- (void)parseXMLFileAtURL:(NSString *)URL {
  NSAutoreleasePool *apool = [[NSAutoreleasePool alloc] init];

  AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

  NSLog(@"parseXMLFileAtURL started.");
  [appDelegate.activityIndicator startAnimating];
  NSLog(@"appDelegate.activityIndicator: %@", appDelegate.activityIndicator);

  articles = [[NSMutableArray alloc] init];

  NSURL *xmlURL = [NSURL URLWithString:URL];

  rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
  [rssParser setDelegate:self];
  [rssParser setShouldProcessNamespaces:NO];
  [rssParser setShouldReportNamespacePrefixes:NO];
  [rssParser setShouldResolveExternalEntities:NO];
  [rssParser parse];

  NSLog(@"parseXMLFileAtURL finished.");
  [appDelegate.activityIndicator stopAnimating];

  [apool release];
}

This method is being called by each view controller as follows:

- (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];

  if ([articles count] == 0) {
    NSString *path = @"http://www.myproject.com/rss1.xml";
    [self performSelectorInBackground:@selector(parseXMLFileAtURL:) withObject:path];
  }
}

This works great while the application loads the first tab’s content. I’m presented with the empty table and the spinner. As soon as the content loads, the spinner goes away.

Strangely, when I click the second tab, the NSLog messages from the -parseXMLFileAtURL: method show up in the log, but the screen hangs on the first tab’s view and I do not see the spinner. As soon as the content is done downloading, the second tab’s view appears.

I suspect this has something to do with threading, with which I’m still becoming acquainted. Am I doing something obviously wrong here?

  • 1 1 Answer
  • 2 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-14T03:04:09+00:00Added an answer on May 14, 2026 at 3:04 am

    You should perform all actions on the activity indicator on the main thread using:

    performSelectorOnMainThread:withObject:waitUntilDone:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

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.