I'm trying to implement a job search App. The results are shown to the user in a UITableView. When a user clicks on a cell, it should open the original Job announcement. To do this, i implemented the following method:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *url = [[NSString alloc]init];
url=[[[xmlParser jobs] objectAtIndex:indexPath.row] urlAddress]; //UrlAddress is an instance variable of type NSString
NSURL *urlJobDetail = [NSURL URLWithString:(url)];
[[UIApplication sharedApplication] openURL: urlJobDetail];
}
The interesting part is: if i type an NSString like @"http://www.google.com" or any other link, it works. But when i try to open a "the urlJobDetail", it just doesn't work... Nothing happens at all...
And i searched it in stackoverflow.com and found this:
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
Than the url works but this method changes the original url address and adds lots of % signs like: "http://www.google.com%20 %20 %20" So i get an page not found error.
I don't understand why this function doesn't accept a regular NSString variable as?
I checked it with NSLog and the url seems to be perfectly in order.
Any help would be much, very much appreciated !
Thanks in advance