Skip to content

Instantly share code, notes, and snippets.

@roothybrid7
Created February 1, 2015 23:12
Show Gist options
  • Save roothybrid7/7232fadcc48e481246f0 to your computer and use it in GitHub Desktop.
Save roothybrid7/7232fadcc48e481246f0 to your computer and use it in GitHub Desktop.
SDWebImageのダウンロード処理を、ネットワークのステータスに応じて制御する ref: http://qiita.com/roothybrid7/items/da1b78a63662e389624d
@implementation APIManager
/*!
@note ネットワーク状況によって、画像ダウンロード処理の停止・再開を行う
*/
+ (void)initialize {
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusReachableViaWWAN:
case AFNetworkReachabilityStatusReachableViaWiFi:
{
[[SDWebImageDownloader sharedDownloader] setSuspended:NO];
break;
}
case AFNetworkReachabilityStatusUnknown:
case AFNetworkReachabilityStatusNotReachable:
default:
{
[[SDWebImageDownloader sharedDownloader] setSuspended:YES];
break;
}
}
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment