不支持的URL错误

时间:2015-03-10 11:43:39

标签: ios nsurl

我有一个包含RSS源文章的表格视图。如果我像这样设置URL,它工作正常:

NSURL *url = [NSURL URLWithString:@"http://kyfbnewsroom.com/category/public-affairs/notifications/feed/"];

但是,我尝试将此类用于多个网址,因此我尝试将URL字符串传递给该类,但在执行此操作时我收到了不受支持的URL错误。

在我的主菜单中选择Feed:

if (indexPath.section == 0)
    {
        if (indexPath.row == 0)
        {
            ActionAlertsViewController *actionAlerts = [[ActionAlertsViewController alloc]initWithStyle:UITableViewStylePlain];
            WebViewController *wvc = [[WebViewController alloc]init];
            [actionAlerts setWebViewController:wvc];
            actionAlerts.urlString = @"http://kyfbnewsroom.com/category/public-affairs/notifications/feed/";
            navController = [[KFBNavControllerViewController alloc]initWithRootViewController:actionAlerts];
            [UIView transitionWithView:appDelegate.window
                              duration:0.5
                               options:UIViewAnimationOptionTransitionFlipFromRight
                            animations:^{
                                appDelegate.window.rootViewController = navController;
                            }
                            completion:nil];
        }

然后在显示文章的表格视图中:

- (void)fetchEntries
{
    xmlData = [[NSMutableData alloc]init];

    // NSURL *url = [NSURL URLWithString:@"http://kyfbnewsroom.com/category/public-affairs/notifications/feed/"];
    NSURL *url = [NSURL URLWithString:self.urlString];

    NSURLRequest *req = [NSURLRequest requestWithURL:url];

    connection = [[NSURLConnection alloc]initWithRequest:req delegate:self startImmediately:YES];
}

1 个答案:

答案 0 :(得分:0)

只需在-(void)fetchEntries上设置一个断点,然后尝试记录self.urlString并验证您是否获得了正确的网址。问题可能是因为网址错误。