Skip to content

Instantly share code, notes, and snippets.

@chuganzy
Last active January 17, 2019 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuganzy/936e5fac1e00e49fdd85 to your computer and use it in GitHub Desktop.
Save chuganzy/936e5fac1e00e49fdd85 to your computer and use it in GitHub Desktop.
SDWebImageのcompleteBlockが呼ばれないことがある http://blog.ganzy.jp/objective-c/191
// どこかでNotificationを受け取れるようにする
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(hc_sdWebImageDownloadStopNotification:)
name:SDWebImageDownloadStopNotification
object:nil];
// 通知を受け取る
- (void)hc_sdWebImageDownloadStopNotification:(NSNotification *)notification {
dispatch_main_async_safe(^{
id obj = notification.object;
if (![obj isKindOfClass:[SDWebImageDownloaderOperation class]]) {
/**
* 現時点(v.3.7.1)ではobjがnilではなくかつ
* SDWebImageDownloaderOperationのインスタンス以外
* になることはなさそうだが念のためチェックする
*/
return;
}
/**
* 現時点(v.3.7.1)ではキャンセル時以外の場合はここに来ることはなさそう
* 後はURLを取ってきたりして好きにする
*/
SDWebImageDownloaderOperation *operation = obj;
NSURL *url = operation.request.URL;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment