[ReactNative] Fix crash on image download

This commit is contained in:
Tadeu Zagallo 2015-04-07 02:43:25 -07:00
parent 397d4666d9
commit 5b3e935332
1 changed files with 8 additions and 7 deletions

View File

@ -77,13 +77,14 @@ static NSString *RCTCacheKeyForURL(NSURL *url)
__weak RCTImageDownloader *weakSelf = self;
RCTCachedDataDownloadBlock runBlocks = ^(BOOL cached, NSData *data, NSError *error) {
RCTImageDownloader *strongSelf = weakSelf;
NSArray *blocks = strongSelf->_pendingBlocks[cacheKey];
[strongSelf->_pendingBlocks removeObjectForKey:cacheKey];
for (RCTCachedDataDownloadBlock block in blocks) {
block(cached, data, error);
}
dispatch_async(_processingQueue, ^{
RCTImageDownloader *strongSelf = weakSelf;
NSArray *blocks = strongSelf->_pendingBlocks[cacheKey];
[strongSelf->_pendingBlocks removeObjectForKey:cacheKey];
for (RCTCachedDataDownloadBlock block in blocks) {
block(cached, data, error);
}
});
};
if ([_cache hasDataForKey:cacheKey]) {