NSURL 基本方法

来源:互联网 发布:python下怎样安装mysql 编辑:程序博客网 时间:2024/05/21 13:59

NSURL *url = [NSURL URLWithString:@"http://www.baidu.com/search?id=1"]; 

NSLog(@"scheme:%@", [url scheme]); //协议 http 

NSLog(@"host:%@", [url host]); //域名 www.baidu.com  

NSLog(@"absoluteString:%@", [url absoluteString]); //完整的url字符串 http://www.baidu.com:8080/search?id=1  

NSLog(@"relativePath: %@", [url relativePath]);//相对路径 search  

NSLog(@"port :%@", [url port]);// 端口 8080  

NSLog(@"path: %@", [url path]);// 路径 search  

NSLog(@"pathComponents:%@", [url pathComponents]); // search  

NSLog(@"Query:%@", [url query]); //参数 id=1

0 0
原创粉丝点击