1.获取本地文件的路径
NSString * location = @"/Users/qianfeng/Desktop/BB/UI/ 图片/未命名文件夹/lxl.jpg";
NSURL * url = [NSURL fileURLWithPath:location];
NSData * dadt = [NSData dataWithContentsOfURL:url];
self.imageView.image = [UIImage imageWithData:dadt];
2.获取网上的路径
NSURL * url = [NSURL URLWithString:@"http://image.lxway.com/thumb/280x220/7/20/72080f282012a5e8e75de1117f1dcc49.jpg"];
NSData * data = [NSData dataWithContentsOfURL:url];
3.*访问网络的文本
NSString * str = @"http://www.sina.com.cn/js/79/2013/0717/fix.js";
NSURL * url = [NSURL URLWithString:str];
NSString * data = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
self.label.text = data;
网友评论