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
网友评论