Jordi Colomé
Jordi Colomé

Reputation: 23

NSURLRequest Null (no encoding problems)

The problem:

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)>

Then if I try:

NSString *str = [[NSString alloc] initWithString:@"http://totssants.com/index.html"];
                                       //which is the actual URL I am trying to load

Everything goes fine... I can pass the string everywhere else but not to the request... Could be that a problem with the XML I am parsing?

Thanks!

Upvotes: 2

Views: 1104

Answers (1)

Josh Hudnall
Josh Hudnall

Reputation: 1031

Try

NSString *str = [theList.artist stringByReplacingOccurrencesOfString:@"\n" withString:@""];
str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

And make sure there is no whitespace at the beginning or end of theList.artist. That will mess it up too. Has happened to me more than once.

Upvotes: 1

Related Questions