美文网首页
NSURL基本方法

NSURL基本方法

作者: 王蓝胖 | 来源:发表于2016-03-11 19:48 被阅读33次

转载自:http://my.oschina.net/wangdk/blog/165554

NSURL *url = [NSURL URLWithString:@"http://www.baidu.com/searchid=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

相关文章

网友评论

      本文标题:NSURL基本方法

      本文链接:https://www.haomeiwen.com/subject/xykxlttx.html