<scheme>://[username:password@]<host[:port]>/<path>[;<params>][?<query>]#<fragment>
NSURL*url=[NSURL URLWithString:@"asdfa://user:password@host:8080/path1/path2;asdfasf=advasdf&asdfalll;;;;=asdf22;parameters3;;;;;;;parmater4;;?key=value&key2=value2#fragmentasd=2asdfas123&&&&fas=12121"];
NSLog(@"%@",url.resourceSpecifier);
NSLog(@"%@",url.scheme);
NSLog(@"%@",url.user);
NSLog(@"%@",url.password);
NSLog(@"%@",url.host);
NSLog(@"%@",url.port);
NSLog(@"%@",url.path);
NSLog(@"%@",url.parameterString);
NSLog(@"%@",url.query);
NSLog(@"%@",url.fragment);
输出结果:
//user:password@host:8080/path1/path2;asdfasf=advasdf&asdfalll;;;;=asdf22;parameters3;;;;;;;parmater4;;?key=value&key2=value2#fragmentasd=2asdfas123&&&&fas=12121
asdfa
user
password
host
8080
/path1/path2
asdfasf=advasdf&asdfalll;;;;=asdf22;parameters3;;;;;;;parmater4;;
key=value&key2=value2
fragmentasd=2asdfas123&&&&fas=12121