Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ios
/
yh_sdwebimage
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
DreamPiggy
7 years ago
Commit
11ffd5a3e712e6af92e66745560ad22b04070d58
1 parent
dbc6b699
capture currentURL instead of using index to access to avoid race condition
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
SDWebImage/SDWebImagePrefetcher.m
SDWebImage/SDWebImagePrefetcher.m
View file @
11ffd5a
...
...
@@ -57,25 +57,21 @@
-
(
void
)
startPrefetchingAtIndex
:
(
NSUInteger
)
index
{
if
(
index
>=
self
.
prefetchURLs
.
count
)
return
;
self
.
requestedCount
++
;
[
self
.
manager
loadImageWithURL
:
self
.
prefetchURLs
[
index
]
options
:
self
.
options
progress
:
nil
completed
:
^
(
UIImage
*
image
,
NSData
*
data
,
NSError
*
error
,
SDImageCacheType
cacheType
,
BOOL
finished
,
NSURL
*
imageURL
)
{
NSURL
*
currentURL
=
self
.
prefetchURLs
[
index
];
[
self
.
manager
loadImageWithURL
:
currentURL
options
:
self
.
options
progress
:
nil
completed
:
^
(
UIImage
*
image
,
NSData
*
data
,
NSError
*
error
,
SDImageCacheType
cacheType
,
BOOL
finished
,
NSURL
*
imageURL
)
{
if
(
!
finished
)
return
;
self
.
finishedCount
++
;
if
(
image
)
{
if
(
self
.
progressBlock
)
{
self
.
progressBlock
(
self
.
finishedCount
,(
self
.
prefetchURLs
).
count
)
;
}
if
(
self
.
progressBlock
)
{
self
.
progressBlock
(
self
.
finishedCount
,(
self
.
prefetchURLs
).
count
)
;
}
else
{
if
(
self
.
progressBlock
)
{
self
.
progressBlock
(
self
.
finishedCount
,(
self
.
prefetchURLs
).
count
)
;
}
if
(
!
image
)
{
// Add last failed
self
.
skippedCount
++
;
}
if
([
self
.
delegate
respondsToSelector
:
@selector
(
imagePrefetcher
:
didPrefetchURL
:
finishedCount
:
totalCount
:)])
{
[
self
.
delegate
imagePrefetcher
:
self
didPrefetchURL
:
self
.
prefetchURLs
[
index
]
didPrefetchURL
:
currentURL
finishedCount
:
self
.
finishedCount
totalCount
:
self
.
prefetchURLs
.
count
]
;
...
...
Please
register
or
login
to post a comment