Avoid crash with nil URL in request

This commit is contained in:
Sam Soffes 2012-02-29 14:35:45 -08:00
parent 8fbe65bc63
commit 34c6dc504b

View File

@ -353,7 +353,10 @@ static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperat
[self.connection cancel];
// Manually send this delegate message since `[self.connection cancel]` causes the connection to never send another message to its delegate
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
NSDictionary *userInfo = nil;
if (self.request.URL) {
userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
}
[self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]];
}
}