Cancel Post request in Afnetworking 2.0

后端 未结 2 1586
清歌不尽
清歌不尽 2021-01-13 10:26

Hi I am making post request using AFnetworking 2.0. My request looks like this.

 AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager mana         


        
2条回答
  •  孤街浪徒
    2021-01-13 10:46

    POST method return the AFHTTPRequestOperation operation. You can cancel it by calling cancel.

    AFHTTPRequestOperation *post =[manager POST:nil parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
      //doing something
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
       // error handling.
    }];
    
    //Cancel operation
    [post cancel];
    

提交回复
热议问题