Last active
January 17, 2019 19:48
-
-
Save chuganzy/936e5fac1e00e49fdd85 to your computer and use it in GitHub Desktop.
SDWebImageのcompleteBlockが呼ばれないことがある http://blog.ganzy.jp/objective-c/191
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// どこかで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