码迷,mamicode.com
首页 > 其他好文 > 详细

QQ电影封装的下载方法

时间:2015-09-13 21:19:22      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

#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

 

QQ电影封装的下载方法

标签:

原文地址:http://www.cnblogs.com/liaods/p/4805455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!