异步GEI (1)
将网址初始化成一个OC字符串对象.
NSString * urlString = @"http://p_w_picpath.zcool.com.cn/56/13/1308200901454.jpg";
NSString * newUrlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
构建网络URL对象
NSURL * URL = [NSURL URLWithString:newUrlString];
创建网络请求
NSURLRequest * request = [NSURLRequest requestWithURL:URL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10];
创建异步连接
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
解析
NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
NSLog(@"%@",dic);
self.p_w_picpathView.p_w_picpath = [UIImage p_w_picpathWithData:data];
}];
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。