dd1079992495
奥克玛项链
2016-03-21 08:28

iOS开发时更新AFNetworking到2.6了,怎么还原成2.0的?

  • ios

新手请问.以下为凑字数:

  #import "AFHTTPRequestOperationManager.h"

#import "AFHTTPSessionManager.h"


/*AFHTTPRequestOperationManager的post有两个方法,一个是普通的post,另一个是可以上传图片的*/

//1.上传图片:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManagermanager];
    manager.responseSerializer.acceptableContentTypes = [NSSetsetWithObject:@"text/html"];

    NSDictionary *parameters =@{@"参数1":@"value1",@"参数2":@"value2"、、、};

    NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"1.png"], 1.0);

    [manager POST:@"替换成你要访问的地址"parameters:parametersconstructingBodyWithBlock:^(id<AFMultipartFormData> formData) {

        [formData appendPartWithFileData :imageData name:@"1" fileName:@"1.png" mimeType:@"image/jpeg"];

    } success:^(AFHTTPRequestOperation *operation,id responseObject) {
        NSLog(@"Success: %@", responseObject);

    } failure:^(AFHTTPRequestOperation *operation,NSError *error) {
        NSLog(@"Error: %@", error);

    }];
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答