foundationkit / FoundationKit

Everything that really should be in Foundation, but isn't. Future-proof with ARC
Other
80 stars 9 forks source link

Block for performing network activity #30

Closed eaigner closed 11 years ago

eaigner commented 13 years ago

I'd like this to NSObject as a category. Any thoughts?

- (void)performNetworkActivity:(dispatch_block_t)block {
  if (block) {
    UIApplication *app = [UIApplication sharedApplication];
    app.networkActivityIndicatorVisible = YES;
    block();
    app.networkActivityIndicatorVisible = NO;
  } 
}

Maybe automatically dispatch the block on another queue too.

eaigner commented 13 years ago

Just realized this issue should be regarding iOSKit instead

myell0w commented 13 years ago

Sounds good, but wouldn't set networkactivityindicator directly, better to use a counting proxy

eaigner commented 13 years ago

But the block balances the YES and NO automatically so it shouldn't be an issue. Or is it?

myell0w commented 13 years ago

If there are more activities going on at the same time the first to finish will deactivate the indicator

eaigner commented 13 years ago

Right.