zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

iOS中NSURL常用属性

ios属性 常用
2023-09-11 14:14:25 时间

 

    NSString *urlstr = @"http://api.test.com:8080/test/index.php?g=api&m=base&a=skyuv&city=110229";
    NSURL *url = [NSURL URLWithString:urlstr];
    NSLog(@"scheme:%@", url.scheme);                    //协议 http
    NSLog(@"host:%@", url.host);                        //域名 api.test.com
    NSLog(@"port:%@", url.port);                        //端口 8080
    NSLog(@"absoluteString:%@", url.absoluteString);    //完整的url字符串
    NSLog(@"relativePath: %@", url.relativePath);       //相对路径 /test/index.php
    NSLog(@"path: %@", url.path);                       //路径 /test/index.php
    NSLog(@"pathComponents:%@", url.pathComponents);    //("/",test,"index.php")
    NSLog(@"Query:%@", url.query);                      //参数 g=api&m=base&a=skyuv&city=110229