总结:
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com:8848/search/path?username=1&password=2"];
//协议 scheme:http
NSLog(@"scheme:%@",[url scheme]);
//域名 host:www.baidu.com
NSLog(@"host:%@",[url host]);
//完整URL字符串 absoluteString:http://www.baidu.com/search/path?username=1&password=2
NSLog(@"absoluteString:%@",[url absoluteString]);
//相对路径 relativePath:/search/path
NSLog(@"relativePath:%@",[url relativePath]);
//端口号 port:8848
NSLog(@"port:%@",[url port]);
//search pathComponent:( "/", search, path)
NSLog(@"pathComponent:%@",[url pathComponents]);
//参数 Query:username=1&password=2
NSLog(@"Query:%@",[url query]);