iOS Afnetwork 3.0 crash: Attempted to create a task in a session that has been invalidated
iOS Afnetwork 3.0 crash: Attempted to create a task in a session that has been invalidated
I am getting a rare crash when I invalidate and cancel AFNetwork session when a user logs out. This is the code I am using right now.
[manager.session invalidateAndCancel];
However, this doesn't work all the time. I get the following crash error.
Attempted to create a task in a session that has been invalidated
This is what requests are being made usually from the App before users logs out and it crashes (I simplified it).
- (void)getFirstData {
[manager GET:url
parameters:nil
progress:nil
success:^(NSURLSessionTask *task, id responseObject) {
[self getSecondData];
}
failure:^(NSURLSessionTask *operation, NSError *error) {
}];
}
- (void)getSecondData {
[manager GET:url
parameters:nil
progress:nil
success:^(NSURLSessionTask *task, id responseObject) {
}
failure:^(NSURLSessionTask *operation, NSError *error) {
}];
}
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.