NSURL*url=[NSURLURLWithString:@www.2cto.com?tn=baiduhome_pg&bs=NSRUL&f=8&rsv_bp=1&rsv_spt=1&wd=NSurl&inputT=2709];
NSLog(@Scheme:%@,[urlscheme]);
NSLog(@Host:%@,[urlhost]);
NSLog(@Port:%@,[urlport]);
NSLog(@Path:%@,[urlpath]);
NSLog(@Relativepath:%@,[urlrelativePath]);
NSLog(@Pathcomponentsasarray:%@,[urlpathComponents]);
NSLog(@Parameterstring:%@,[urlparameterString]);
NSLog(@Query:%@,[urlquery]);
NSLog(@Fragment:%@,[urlfragment]);
NSLog(@User:%@,[urluser]);
NSLog(@Password:%@,[urlpassword]);
结果如下:
2012-03-3118:22:20.904SmallDemoList[5473:11603]12131232
2012-03-3118:22:20.907SmallDemoList[5473:11603]Scheme:http
2012-03-3118:22:20.907SmallDemoList[5473:11603]Host:www.baidu.com
2012-03-3118:22:20.907SmallDemoList[5473:11603]Port:(null)
2012-03-3118:22:20.907SmallDemoList[5473:11603]Path:/s
2012-03-3118:22:20.907SmallDemoList[5473:11603]Relativepath:/s
2012-03-3118:22:20.907SmallDemoList[5473:11603]Pathcomponentsasarray:(
/,
s
)
2012-03-3118:22:20.916SmallDemoList[5473:11603]Parameterstring:(null)
2012-03-3118:22:20.917SmallDemoList[5473:11603]Query:tn=baiduhome_pg&bs=NSRUL&f=8&rsv_bp=1&rsv_spt=1&wd=NSurl&inputT=2709
2012-03-3118:22:20.917SmallDemoList[5473:11603]Fragment:(null)
2012-03-3118:22:20.917SmallDemoList[5473:11603]User:(null)
2012-03-3118:22:20.917SmallDemoList[5473:11603]Password:(null)
4:根据文件名称和文件后缀获取程序包内容文件的路径
NSURL*urlKindEditor = [[NSBundlemainBundle]URLForResource:@simplewithExtension:@htmlsubdirectory:@KindEditor/examples];
URLForResource:文件名称
withExtension:文件后缀
subdirectory:在程序包中的哪个子目录中寻找.
如果没有找到将会返回nil
找到后返回如下路径:file://localhost/Users/amarishuyi/Library/Application Support/iPhone Simulator/5.1/Applications/FB0CDABC-D0E2-45FF-AA2C-959E8A65ADB4/SmallDemoList.app/KindEditor/examples/simple.html