总结:带file的方法都是获取本地的资源;
// 1. 获取文件本地路径
NSString *path = [[NSBundle mainBundle]pathForResource:@"cars_simple.plist"ofType:nil];
// 2. 从本地路径读取文件内容到临时数组中
NSArray *tempArray = [NSArray arrayWithContentsOfFile:path];
//通过上面的本地路径获取url
NSURL *url=[NSURL fileURLWithPath:path];
//通过网址获取url
NSURL *url=[NSURL URLWithString:@"http://www.baidu.com"];
//本地路径中获取data数据
NSData *emoticonData = [NSData dataWithContentsOfFile:filePath];
URL中的scheme:协议,例如http、rtmp等;
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com/search?id=1"];
[url scheme] //协议 http
[url host] //域名 www.baidu.com
[url absoluteString] //完整的url字符串 http://www.baidu.com:8080/search?id=1
[url relativePath] //相对路径,域名斜杠后问好前的部分 search
[url port] // 端口 8080
[url path]// 路径 search
[url pathComponents] // search
[url query] //参数 id=1