Skip to content

Instantly share code, notes, and snippets.

@amudi
Created January 13, 2011 06:33
Show Gist options
  • Save amudi/777490 to your computer and use it in GitHub Desktop.
Save amudi/777490 to your computer and use it in GitHub Desktop.
[iOS] centralized network activity indicator counter
@interface UIApplication (NetworkActivityIndicator)
- (void)increaseActiveRequests;
- (void)decreaseActiveRequests;
@end
@implementation UIApplication (NetworkActivityIndicator)
static int counter = 0;
- (void)increaseActiveRequests {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:(++counter > 0)];
}
- (void)decreaseActiveRequests {
if (--counter < 0) counter = 0;
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:(counter > 0)];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment