标签:
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(@"请求成功"); }];
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); }];
标签:
原文地址:http://www.cnblogs.com/Rinpe/p/5067422.html