NSUrl

    NSString *urlString = [NSString stringWithFormat:@"http://www.baidu.com/search?id=1"];

    NSURL __unused *url = [NSURL URLWithString:urlString];

    NSLog(@"协议===%@\n",[url scheme]);// 协议

    NSLog(@"域名==%@\n",[url host]);// 域名

    NSLog(@"完整的url字符串==%@\n",[url absoluteString]);//完整的url字符串

    NSLog(@"relativePath: %@", [url relativePath]); //相对路径 search

    NSLog(@"port :%@", [url port]);  // 端口

    NSLog(@"path: %@", [url path]);  // 路径 search

    NSLog(@"pathComponents:%@", [url pathComponents]); // search

    NSLog(@"Query:%@", [url query]);  //参数 id=1

 

 

 11:03:22.145 ExerciseCopyRetain[1141:29782] 协议===http

 11:03:22.146 ExerciseCopyRetain[1141:29782] 域名==www.baidu.com

 11:03:22.146 ExerciseCopyRetain[1141:29782] 完整的url字符串==http://www.baidu.com/search?id=1

 11:03:22.146 ExerciseCopyRetain[1141:29782] relativePath: /search

 11:03:22.146 ExerciseCopyRetain[1141:29782] port :(null)

 11:03:22.147 ExerciseCopyRetain[1141:29782] path: /search

 11:03:22.147 ExerciseCopyRetain[1141:29782] pathComponents:(

    "/",

    search

)

 11:03:22.147 ExerciseCopyRetain[1141:29782] Query:id=1

posted @ 2016-01-28 11:11  徒步阳光855  阅读(134)  评论(0编辑  收藏  举报