• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Showing activity indicator during data download
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Showing activity indicator during data download


  • Subject: Re: Showing activity indicator during data download
  • From: Claus Guttesen <email@hidden>
  • Date: Thu, 29 Oct 2009 10:26:41 +0100

> I've implemented an update button like this:
>
> - (IBAction)updateButton:(id)sender
> {
>   [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
>   [downloadIndicator startAnimating];
>
>   [[DataManager sharedDataManager] updateDataFiles];
>
>   [downloadIndicator stopAnimating];
>   [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
> }
>
> And in the DataManager class I have this:
>
> - (void)updateDataFiles
> {
>   NSString *dataString = [NSString stringWithContentsOfURL:url
>      encoding:NSASCIIStringEncoding
>      error:NULL];
> }
>
> I have the downloadIndicator connected up using IB, and I'm pretty sure the
> wiring is OK. But when the button is clicked, I see an activity indicator
> spinning in the status bar, but I don't see the one I implemented myself
> using IB.
>
> I know it's got something to do with my updateDataFiles method not being
> asynchronous, but beyond that I'm at a loss. I'd really rather avoid writing
> the extra code to do the download using NSURLConnection mechanisms: the user
> can't do anything until the download finishes anyway.
>
> I'd like to have an alert panel or the second activity indicator visible
> during the download. Can someone point me towards a simple solution?

Did you define an outlet in the interface-statement (h-file) for your class? Ie.

@interface MyViewController : UIViewController {
   ...
   IBOutlet UIActivityIndicatorView *activityIndicatorView;
   ...
}

@property (nonatomic, retain) IBOutlet UIActivityIndicatorView
*activityIndicatorView;

Don't forget to synthesize in the implementation file.

When the activity indicator is connected you can do a
activityIndicatorView.startAnimating; and stopAnimating.

HTH.

--
regards
Claus

When lenity and cruelty play for a kingdom,
the gentler gamester is the soonest winner.

Shakespeare

twitter.com/kometen
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Showing activity indicator during data download (From: DKJ <email@hidden>)

  • Prev by Date: Re: A distinct group of pictures in the bundle
  • Next by Date: Re: Cocoa replacement for Carbon CompositeIconRef() for Snow Leopard 64-bit apps?
  • Previous by thread: Re: Showing activity indicator during data download
  • Next by thread: Re: Showing activity indicator during data download
  • Index(es):
    • Date
    • Thread