總結(jié):
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com:8848/search/path?username=1&password=2"];
//協(xié)議 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]);
//參數(shù) Query:username=1&password=2
NSLog(@"Query:%@",[url query]);
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者