// 取消请求
// 仅仅是取消请求, 不会关闭session
[self.manager.tasks makeObjectsPerformSelector:@selector(cancel)];
// 关闭session并且取消请求(session一旦被关闭了, 这个manager就没法再发送请求)
[self.manager invalidateSessionCancelingTasks:YES];
self.manager = nil;
// 一个任务被取消了, 会调用AFN请求的failure这个block
[task cancel];
网友评论
Attempted to create a task in a session that has been invalidated
Terminating app due to uncaught exception 'NSGenericException', reason: 'Task created in a session that has been invalidated'
崩了
The operation queue on which delegate callbacks are run.
*/
@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue;这个queue是代理的queue,不是网络任务的queue。