Skip to content

Commit

Permalink
Merge pull request AFNetworking#2432 from NSElvis/improve/UIRefreshCo…
Browse files Browse the repository at this point in the history
…ntrol

UIRefreshControl should react over task with completed state
  • Loading branch information
mattt committed Nov 17, 2014
2 parents 568f9fe + e2805f7 commit 85f2bae
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions UIKit+AFNetworking/UIRefreshControl+AFNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
[notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];

if (task) {
if (task.state != NSURLSessionTaskStateCompleted) {
if (task.state == NSURLSessionTaskStateRunning) {
[self beginRefreshing];
} else {
[self endRefreshing];
}
if (task.state == NSURLSessionTaskStateRunning) {
[self beginRefreshing];

[notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task];
[notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task];
[notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task];
} else {
[self endRefreshing];
}
}
}
Expand Down

0 comments on commit 85f2bae

Please sign in to comment.