How to do GET request via AFNetworking?

后端 未结 5 1342
你的背包
你的背包 2020-12-31 16:49

I added directories AFNetworking and UIKit+AFNetworking to project manager. I use latest library 3.0.4

After I imported file AFNetwor

5条回答
  •  被撕碎了的回忆
    2020-12-31 16:55

    (void)postDatabyAF{
    
    NSString *url;
    
    NSDictionary *dict;
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    
    manager.responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:
                                  NSJSONReadingAllowFragments];
    
    [manager POST:url parameters:dict success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
    
        NSLog(@" operation.responseData  %@",operation.responseData);
        NSLog(@" operation.response %@",operation.response);
        NSLog(@"statusCode %ld",operation.response.statusCode);
    
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
    
        if (error) {
    
        }
        else{
    
    
        }
    }];
    

    }

提交回复
热议问题