NSURL *url = [NSURL URLWithString:@"http://www.baidu.com/search?id=1"];
NSLog(@"scheme:%@",[url scheme]);//协议http
NSLog(@"host:%@",[url host]);//域名www.baidu.com
NSLog(@"absolutestring:%@",[url absoluteString]);//完整的url字符串
NSLog(@"relativepath:%@",[url relativePath]);//相对路径 search
NSLog(@"port:%@",[url port]);//端口
NSLog(@"path:%@",[url path]);//路径
NSLog(@"pthcomponents:%@",[url pathComponents]);//search
NSLog(@"query:%@",[url query]);//参数
打印如下:
仅做记录!