Permalink
Browse files

Responsibly invalidate the timeoutTimer when the RKRequest is dealloc…

…ated. Move location of timer creation for asynchronous request.
  • Loading branch information...
bmorton authored and blakewatters committed Jan 5, 2012
1 parent 15d05f1 commit dab403a9c1481977043f330f1b65462ad33ce472
Showing with 4 additions and 0 deletions.
  1. +4 −0 Code/Network/RKRequest.m
View
@@ -171,6 +171,9 @@ - (void)dealloc {
_OAuth2AccessToken = nil;
[_OAuth2RefreshToken release];
_OAuth2RefreshToken = nil;
+ [self invalidateTimeoutTimer];
+ [_timeoutTimer release];
+ _timeoutTimer = nil;
// Cleanup a background task if there is any
[self cleanupBackgroundTask];
@@ -377,6 +380,7 @@ - (void)fireAsynchronousRequest {
RKResponse* response = [[[RKResponse alloc] initWithRequest:self] autorelease];
_connection = [[NSURLConnection connectionWithRequest:_URLRequest delegate:response] retain];
+ _timeoutTimer = [NSTimer scheduledTimerWithTimeInterval:self.timeoutInterval target:self selector:@selector(timeout) userInfo:nil repeats:NO];
[[NSNotificationCenter defaultCenter] postNotificationName:RKRequestSentNotification object:self userInfo:nil];
}

0 comments on commit dab403a

Please sign in to comment.