标签:
#import "NetWorkManage.h" #import "NetWorkInterface.h" #import "AFHTTPRequestOperationManager.h" #import "SDWebImageManager.h" @implementation NetWorkManage //一.电影模块 //中间滚动视图数据 + (void)getMidDataSuccess:(SuccessBlock)success Failure:(Failure)failure { //(@"sign=94F244AA6BA02799485762014E5EC196&appkey=9&v=2015061201&t=1439627000&from=0123456789&city=82") NSDictionary *dic = @{@"sign":@"94F244AA6BA02799485762014E5EC196",@"appkey":@"9",@"v":@"2015061201",@"t":@"1439627000",@"from":@"0123456789",@"city":@"82"}; [self downloadaWithDic:dic andUrl:kMidScrollView Success:success Failure:failure]; } //post 请求 + (void)downloadaWithDic:(NSDictionary *)dic andUrl:(NSString *)url Success:(SuccessBlock)success Failure:(Failure)failure { AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; [manager POST:url parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) { success(responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { failure(error); }]; } //get请求 + (void)downloadWithUrl:(NSString *)url whenSuccess:(SuccessBlock)success andFailure:(Failure)failure { AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; [manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { success(responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { failure(error); }]; } //下载图片 + (void)getImageWithUrl:(NSString *)url whenSuccess:(ImgSuccessBlock)success { SDWebImageManager *manager = [SDWebImageManager sharedManager]; [manager downloadImageWithURL:[NSURL URLWithString:url] options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { if (image) { success(image); } }]; } @end
标签:
原文地址:http://www.cnblogs.com/liaods/p/4805455.html