?后是第一個參數(shù)
&后是后面的參數(shù)
NSURL *url = [NSURL URLWithString:@"http://www.baidu.com/search?id=1"];
NSLog(@"scheme:%@", [url scheme]); //協(xié)議 http
NSLog(@"host:%@", [url host]); //域名 www.baidu.com
NSLog(@"absoluteString:%@", [url absoluteString]); //完整的url字符串 http://www.baidu.com:8080/search?id=1 (剛才在真機上跑了一下,并沒有打印出來端口 8080 啊)
NSLog(@"relativePath: %@", [url relativePath]); //相對路徑 search
NSLog(@"port :%@", [url port]); // 端口 8080
NSLog(@"path: %@", [url path]); // 路徑 search
NSLog(@"pathComponents:%@", [url pathComponents]); // search
NSLog(@"Query:%@", [url query]); //參數(shù) id=1