NSURL

作者: iLeooooo | 来源:发表于2017-11-02 10:51 被阅读4次

?后是第一个参数
&后是后面的参数

   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   (刚才在真机上跑了一下,并没有打印出来端口 8080 啊)

   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/opsilxtx.html