NSURL的常用属性

    NSString *urlstr = @"http://qq.test.com:666/test?index=0&name=haha";
    NSURL *url = [NSURL URLWithString:urlstr];
    NSLog(@"scheme:%@", url.scheme);                    //协议 http
    NSLog(@"host:%@", url.host);                        //域名 qq.test.com
    NSLog(@"port:%@", url.port);                        //端口 666
    NSLog(@"absoluteString:%@", url.absoluteString);    //完整的url字符串:
    NSLog(@"relativePath: %@", url.relativePath);       //相对路径 /test
    NSLog(@"path: %@", url.path);                       //路径 /test
    NSLog(@"pathComponents:%@", url.pathComponents);    //("/",test,"index.php")
    NSLog(@"Query:%@", url.query);                      //参数 index=0&name=haha
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容