问题:
NSString *str = [[NSString alloc] initWithString:theList.artist];
NSLog(@"%@",str); // Log gives me the correct string...
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:str]];
[self.webView loadRequest:request];
NSLog(@"%@", request); //Log returns <NSURLRequest (null)>
然后,如果我尝试:
NSString *str = [[NSString alloc] initWithString:@"http://totssants.com/index.html"];
//which is the actual URL I am trying to load
一切都很顺利...我可以将字符串传递给其他地方但不是请求... 可能是我正在解析的XML问题吗?
谢谢!
答案 0 :(得分:1)
尝试
NSString *str = [theList.artist stringByReplacingOccurrencesOfString:@"\n" withString:@""];
str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
确保theList.artist
的开头或结尾没有空格。这也会搞砸了。不止一次发生在我身上。