Skip to content

Commit

Permalink
Move block calls so they're always after delegate calls, but before q…
Browse files Browse the repository at this point in the history
…ueue calls
  • Loading branch information
pokeb committed Apr 11, 2011
1 parent 3d6dbb3 commit ce1db2e
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions Classes/ASIHTTPRequest.m
Expand Up @@ -1857,14 +1857,14 @@ - (void)requestStarted
if (delegate && [delegate respondsToSelector:didStartSelector]) {
[delegate performSelector:didStartSelector withObject:self];
}
if (queue && [queue respondsToSelector:@selector(requestStarted:)]) {
[queue performSelector:@selector(requestStarted:) withObject:self];
}
#if NS_BLOCKS_AVAILABLE
if(startedBlock){
startedBlock();
}
#endif
if (queue && [queue respondsToSelector:@selector(requestStarted:)]) {
[queue performSelector:@selector(requestStarted:) withObject:self];
}
}

/* ALWAYS CALLED ON MAIN THREAD! */
Expand All @@ -1877,6 +1877,7 @@ - (void)requestRedirected
if([[self delegate] respondsToSelector:@selector(requestRedirected:)]){
[[self delegate] performSelector:@selector(requestRedirected:) withObject:self];
}

#if NS_BLOCKS_AVAILABLE
if(requestRedirectedBlock){
requestRedirectedBlock();
Expand All @@ -1895,15 +1896,16 @@ - (void)requestReceivedResponseHeaders:(NSMutableDictionary *)newResponseHeaders
if (delegate && [delegate respondsToSelector:didReceiveResponseHeadersSelector]) {
[delegate performSelector:didReceiveResponseHeadersSelector withObject:self withObject:newResponseHeaders];
}
if (queue && [queue respondsToSelector:@selector(request:didReceiveResponseHeaders:)]) {
[queue performSelector:@selector(request:didReceiveResponseHeaders:) withObject:self withObject:newResponseHeaders];
}


#if NS_BLOCKS_AVAILABLE
if(headersReceivedBlock){
headersReceivedBlock(newResponseHeaders);
}
#endif

if (queue && [queue respondsToSelector:@selector(request:didReceiveResponseHeaders:)]) {
[queue performSelector:@selector(request:didReceiveResponseHeaders:) withObject:self withObject:newResponseHeaders];
}
}

/* ALWAYS CALLED ON MAIN THREAD! */
Expand Down Expand Up @@ -1940,14 +1942,16 @@ - (void)requestFinished
/* ALWAYS CALLED ON MAIN THREAD! */
- (void)reportFinished
{
#if NS_BLOCKS_AVAILABLE
if(completionBlock){
completionBlock();
}
#endif
if (delegate && [delegate respondsToSelector:didFinishSelector]) {
[delegate performSelector:didFinishSelector withObject:self];
}

#if NS_BLOCKS_AVAILABLE
if(completionBlock){
completionBlock();
}
#endif

if (queue && [queue respondsToSelector:@selector(requestFinished:)]) {
[queue performSelector:@selector(requestFinished:) withObject:self];
}
Expand All @@ -1959,14 +1963,16 @@ - (void)reportFailure
if (delegate && [delegate respondsToSelector:didFailSelector]) {
[delegate performSelector:didFailSelector withObject:self];
}
if (queue && [queue respondsToSelector:@selector(requestFailed:)]) {
[queue performSelector:@selector(requestFailed:) withObject:self];
}

#if NS_BLOCKS_AVAILABLE
if(failureBlock){
failureBlock();
}
#endif

if (queue && [queue respondsToSelector:@selector(requestFailed:)]) {
[queue performSelector:@selector(requestFailed:) withObject:self];
}
}

/* ALWAYS CALLED ON MAIN THREAD! */
Expand Down

0 comments on commit ce1db2e

Please sign in to comment.