[統(tǒng)一資源名](URN)如同一個人的名稱,而[統(tǒng)一資源定位符](URL)代表一個人的住址购城。URI可被視為定位符(URL),名稱(URN)或兩者兼?zhèn)?/p>
NSURL *url = [NSURL URLWithString:@"http://user:password@www.example.com:8080/hoge/fuga/index.html?a=1&b=2#test"];
NSLog(@"absoluteString : %@", [url absoluteString]); NSLog(@"absoluteURL : %@", [url absoluteURL]); NSLog(@"baseURL : %@", [url baseURL]);
NSLog(@"fragment : %@", [url fragment]);
NSLog(@"host : %@", [url host]);
NSLog(@"lastPathComponent : %@", [url lastPathComponent]);
NSLog(@"parameterString : %@", [url parameterString]);
NSLog(@"password : %@", [url password]);
NSLog(@"path : %@", [url path]);
NSLog(@"pathComponents : %@", [url pathComponents]);
NSLog(@"pathExtension : %@", [url pathExtension]);
NSLog(@"port : %@", [url port]); NSLog(@"query : %@", [url query]);
NSLog(@"relativePath : %@", [url relativePath]);
NSLog(@"relativeString : %@", [url relativeString]);
NSLog(@"resourceSpecifier : %@", [url resourceSpecifier]);
NSLog(@"scheme : %@", [url scheme]);
NSLog(@"standardizedURL : %@", [url standardizedURL]);
NSLog(@"user : %@", [url user]);
維基百科:https://zh.wikipedia.org/wiki/%E7%BB%9F%E4%B8%80%E8%B5%84%E6%BA%90%E6%A0%87%E5%BF%97%E7%AC%A6
我在項目中使用的是url.scheme用來判斷是否是我需要的站欺。
比如url是:http://user:password@www.example.com:8080/hoge/fuga/index.html?a=1&b=2#test
url.scheme返回的是:http.
我就判斷這個就可以滿足我的工作需求。