Very simple class to add queue functionality to the iPhone Network Activity Indicator
Objective-C
Pull request Compare This branch is 2 commits ahead of appcorn:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ACActivityIndicatorQueue.h
ACActivityIndicatorQueue.m
LICENSE
README.mdown

README.mdown

ACActivityIndicatorQueue

This simple class provieds a convinient way of queueing the visibility state of the Network Activity Indicator on the iPhone.

Usage

To queue activity just use the two static methods from any part/thread of your application:

- (void)makeRESTCall {
    // First request
    [ACActivityIndicatorQueue startActivity];
    [NSURLConnection connectionWithRequest:request1 delegate:self];

    // Seccond request
    [ACActivityIndicatorQueue startActivity];
    [NSURLConnection connectionWithRequest:request2 delegate:self];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    [ACActivityIndicatorQueue endActivity];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
    [ACActivityIndicatorQueue endActivity];
}

- (void)cancelAllRequestsButtonPressed:(id)sender {
    [ACActivityIndicatorQueue resetAndStopActivity];
}

Your Network Activity Indicator will correctly reflect the status of network activity, even if you atempt to show and hide the indicator from different parts of the code asynchronous.

The resetAndStopActivity method will reset the queue, forcing the indicator to be hidden immediately. (Thanks Jens! http://github.com/jk/ACActivityIndicatorQueue/commit/ec7b411cda39acc04969c03b25fabcc41d962bfc )

License

ACActivityIndicatorQueue is released under the MIT-license (see the LICENSE file)