您的位置:首页 > 移动开发 > IOS开发

iOS巅峰之NSURL 基本方法 absoluteString

2016-02-22 15:51 489 查看
NSURL
*url = [NSURL URLWithString:@
"http://www.baidu.com/search?id=1"
];
2
NSLog(@
"scheme:%@"
,
[url scheme]);
//协议
http
3
NSLog(@
"host:%@"
,
[url host]);
//域名
www.baidu.com
4
NSLog(@
"absoluteString:%@"
,
[url absoluteString]);
//完整的url字符串 http://www.baidu.com:8080/search?id=1[/code]
(刚才在真机上跑了一下,并没有打印出来端口 8080 啊)

5
NSLog(@
"relativePath:
%@"
,
[url relativePath]);
//相对路径
search
6
NSLog(@
"port
:%@"
,
[url port]);
//
端口 8080
7
NSLog(@
"path:
%@"
,
[url path]);
//
路径 search
8
NSLog(@
"pathComponents:%@"
,
[url pathComponents]);
//
search
9
NSLog(@
"Query:%@"
,
[url query]);
//参数
id=1

详细介绍:http://my.oschina.net/wangdk/blog/165554
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: