How to cancel network request with afnetworking

后端 未结 3 1880
盖世英雄少女心
盖世英雄少女心 2020-12-09 10:24

Is there a way to cancel all network request (the request started by another method) before I do a network request with AFNetworking I tried like below but not work:

相关标签:
3条回答
  • 2020-12-09 10:40

    [[httpClient operationQueue] cancelAllOperations];

    0 讨论(0)
  • 2020-12-09 10:40

    Both the other two answers are right. Don't Create new AFHTTPRequestOperationManager instance

            @interface OperateCustomerView () <WYPopoverControllerDelegate>{
    
            AFHTTPRequestOperationManager *manager;// = [AFHTTPRequestOperationManager manager];
        }
    - (void)viewDidLoad {
        [super viewDidLoad];
        manager = [AFHTTPRequestOperationManager manager];
    
    0 讨论(0)
  • 2020-12-09 10:56

    Don't Create new AFHTTPClient instance.

    try "[self cancelAllHTTPOperationsWithMethod:@"POST" path:@"product/like"];

    0 讨论(0)
提交回复
热议问题