关闭

NSURLSession代理方法

342人阅读 评论(0) 收藏 举报
分类:

//首先要遵循《NSURLSessionDataDelegate》


- (void)viewDidLoad {

    [super viewDidLoad];

    


//    [self getTouchTask];

    

    NSURLSession *session =[NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[[NSOperationQueue alloc]init]];

    NSURLSessionDataTask *task = [session dataTaskWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://120.25.226.186:32812/resources/image/minion_01.image"]]];

    [task resume];

}


- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask

didReceiveResponse:(NSURLResponse *)response

 completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler

{

    completionHandler(NSURLSessionResponseAllow);


}



- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask

    didReceiveData:(NSData *)data{

    

    NSLog(@"%s",__func__);

}



- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task

didCompleteWithError:(nullable NSError *)error

{


}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:13511次
    • 积分:535
    • 等级:
    • 排名:千里之外
    • 原创:40篇
    • 转载:4篇
    • 译文:1篇
    • 评论:4条