AFNetworking 3.0的POST请求使用方法
AFHTTPSessionManager *session = [AFHTTPSessionManager manager]; session.requestSerializer = [AFJSONRequestSerializer serializer]; NSMutableDictionary *params = [NSMutableDictionary dictionary]; params[@"start"] = @"1"; params[@"end"] = @"5"; [session POST:urlStr parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSLog(@"请求成功"); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { NSLog(@"请求成功"); }];
AFNetworking 3.0的GET请求使用方法
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; [manager GET:@"http://example.com/resources.json" parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(NSURLSessionTask *operation, NSError *error) { NSLog(@"Error: %@", error); }];