你用就可以了:
NSString *myUrl = @"http://clickfrom.buy.com/default.asp?adid\\u003d17379&sURL\\u003dhttp%3A%2F%2Fwww.buy.com%2Fprod%2Fkimberly-clark-professional-kleenex-boutique-white-facial-tissue-2-ply%2Fq%2Floc%2F66357%2F211347223.html";
NSURL *url = [NSURL URLWithString:myUrl];
NSLog(@"%@", [url host]);
編輯
序列
\u003d
在一個NSString被解釋爲普遍性,所以它必須被引用爲我們例如:
\\u003d
而且會導致錯誤:\ u003d不是有效的通用字符。仍然存在解析問題,因爲反斜槓在URI語法中似乎是無效的字符。它必須被百分比逃脫。
看看RFC 2396/2.4.3。排除的US-ASCII字符
...
Other characters are excluded because gateways and other transport
agents are known to sometimes modify such characters, or they are
used as delimiters.
unwise = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
Data corresponding to excluded characters must be escaped in order to
be properly represented within a URI.
這樣做
NSString *myUrl = [@"http://clickfrom.buy.com/default.asp?adid\\u003d17379&sURL\\u003dhttp%3A%2F%2Fwww.buy.com%2Fprod%2Fkimberly-clark-professional-kleenex-boutique-white-facial-tissue-2-ply%2Fq%2Floc%2F66357%2F211347223.html" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
應該讓分析工作。
請參閱下面的評論,我越來越Null.I我得到的數組中的值的鏈接 – Sabby 2011-05-11 10:15:44