-(void)downloadWithUrl:(NSURL *)url compelet:(DownLoadBlock)block {
//保存block
self.block = block;
//创建队列
dispatch_queue_t queue = dispatch_queue_create(nil, DISPATCH_QUEUE_CONCURRENT);
dispatch_async(queue, ^{
//执行下载任务
//创建请求
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
//获取数据
NSData *date = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
//将数据返回给调用者
dispatch_sync(dispatch_get_main_queue(), ^{
self.block(date);
});
});
}
获取数据的方法好像是ios9.0之后就不能用了,现在怎么获取,