I made a subclass of AFHTTPRequestOperationManager
and wanted to set timeout to 3 seconds.
[netMgr.requestSerializer setTimeoutInterval:3.f];
But it doesn't work.
I can figure out that it's because the auto key value observing returns NO
in automaticallyNotifiesObserversForKey
when the key is timeoutInterval
Could anyone tell me the reason, or What's the right way to set timeout of request ?
I agree. Twenty-one days ago, the commit 0f3829f turned off automatic notification for these properties. It's the observer for these properties that ensures that any request serializer property changes translate to modification of the NSMutableURLRequest
object for requests issued via AFHTTPRequestOperationManager
.
I have to assume mattt had a reason for turning off this notification (looks like it is in response to issue #2523 , which should probably be reconsidered), so until this is remedied, I'd suggest one merely manually posting the notification.
[manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];
manager.requestSerializer.timeoutInterval = ...;
[manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
Note, this was fixed 26 March 2015 in commit 7d8e286 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.