View Single Post
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 158
Mark FX has a spectacular aura about

Mark FX is offline
I would first create an IBOutlet variable for the UIActivityIndicatorView class, in the header
file for your controller class, and add the NSURLConnection protocol attribute to the class,
like this.

Code:
@interface className : NSObject  <NSURLConnectionProtocol>
{
        IBOutlet  UIActivityIndicatorView  *activityIndicator ;
}
Then connect the ActivityIndicatorView in your xib file to this outlet, also set the hidden
property to true, and the hides when stopped property to true, using the attributes inspector.

then you would call the startAnimating: method on the activityIndicator variable, from the
method you use to start the NSURLConnection request, like this.

Code:
- (void)startConnection
{
      [activityIndicator startAnimating] ;
}
And use the stopAnimating: method of the activityIndicator, from the method you use to
verify the connection data has been recieved, like this.

Code:
- (void)stopConnection
{
      [activityIndicator stopAnimating] ;
}
In iOS 4.3 the NSURLConnection has a connectionDidFinishLoading : method, and a
delegate method connection : didFailWithError : , which you could use to stop the
activity indicator in either case, but I'm not sure if these methods are still available in iOS 5.

Check out the developer documentation, on the NSURLConnection class, and delegate
methods to find the appropriate methods for checking the completed download.

This guide is probably worth reading as well.

https://developer.apple.com/library/.../uid/10000165i

Hope this is of some help.

Regards Mark
QUOTE Thanks