美文网首页
NSURL 起底

NSURL 起底

作者: 踏云小子 | 来源:发表于2017-08-03 14:47 被阅读11次

    show me the code

    NSString *url_ = @"foo://name.com:8080/12345;param?foo=1&baa=2#fragment";
    NSURL *url = [NSURL URLWithString:url_];
    
    NSLog(@"scheme: %@", [url scheme]); 
    NSLog(@"host: %@", [url host]); 
    NSLog(@"port: %@", [url port]);     
    NSLog(@"path: %@", [url path]);     
    NSLog(@"path components: %@", [url pathComponents]);        
    NSLog(@"parameterString: %@", [url parameterString]);   
    NSLog(@"query: %@", [url query]);       
    NSLog(@"fragment: %@", [url fragment]);
    

    打印如下

    scheme: foo
    host: name.com
    port: 8080
    path: /12345
    path components: (
        "/",
        12345
    )
    parameterString: param
    query: foo=1&baa=2
    fragment: fragment
    

    相关文章

      网友评论

          本文标题:NSURL 起底

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