Chinaunix首页 | 论坛 | 博客
  • 博客访问: 18483
  • 博文数量: 8
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 65
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-22 22:39
文章分类

全部博文(8)

文章存档

2016年(2)

2015年(6)

我的朋友

分类: iOS平台

2016-01-27 11:20:17

刚学线程通信,提示:

2016-01-27 11:11:02.246 20-9 gcd3 communicationOfThread[5193:298643] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

原来是因为 iOS9之后,原http协议被改成了https协议,使用 TLS1.2 SSL加密请求数据。

在info.plist中添加
NSAppTransportSecurity
    NSAllowsArbitraryLoads
    

即可

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_async(queue, ^{
        NSLog(@"url:%@",[NSThread currentThread]);
        NSURL *url = [NSURL URLWithString:@""];
        NSData *data = [NSData dataWithContentsOfURL:url];
        UIImage *image = [UIImage imageWithData:data];
        NSLog(@"url:%@,image:%@",[NSThread currentThread],image);

        dispatch_async(dispatch_get_main_queue(), ^{
            NSLog(@"downLoad:%@,image:%@",[NSThread currentThread],image);

            [self.btn setBackgroundImage:image  forState:UIControlStateNormal];
        });
    });
    
}

阅读(359) | 评论(0) | 转发(0) |
0

上一篇:xcode7 没有Empty Application

下一篇:没有了

给主人留下些什么吧!~~