1.使用AFNetworking的GET POST请求:
GET代码如下:
AFHTTPRequestOperationManager *httpManager=[AFHTTPRequestOperationManager manager];
httpManager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];//设置相应内容类型
[httpManager GET:@"url" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"xx%@",responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"xx%@",error);
}];
POST代码:
AFHTTPRequestOperationManager *httpManager=[AFHTTPRequestOperationManager manager];
httpManager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];//设置相应内容类型
[httpManager POST:@"url" parameters:@"参数字典" success:^(AFHTTPRequestOperation *operation, id responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
POST上传文件,图片等使用的方法
[httpManager POST:@"url" parameters:@"参数字典" constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
//文件处理
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
//成功返回参数
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//失败返回参数
}];
2.图片显示:(缓存到内存是缓存到了系统内存中,就是程序运行时候用到的系统内存,这样会提高读取速度。保留的时间应该是在程序运行期间都没有问题,但是当内存吃紧的时候,AFNetworking可能会自动清空系统缓存,和sdwebimage差不多)
[headImage setImageWithURL:[NSURL URLWithString:@"http://www.qzfczy.com/uploads/zf/140717sf14055836251137.png"] placeholderImage:nil];
//等待更新。。。。探索中。。。。