【发布时间】:2015-05-11 20:10:30
【问题描述】:
我有一个表格视图,其中包含来自 RSS 提要的文章。如果我这样设置 URL,它工作正常:
NSURL *url = [NSURL URLWithString:@"http://kyfbnewsroom.com/category/public-affairs/notifications/feed/"];
但是,我正在尝试将此类用于多个 URL,因此我正在尝试将 URL 字符串传递给该类,但是这样做时出现了不受支持的 URL 错误。
在我的主菜单中选择一个提要:
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];
}
【问题讨论】:
-
尝试在控制台打印url,看看两个url有什么修改
-
你能发布完整的代码吗?你在哪里调用这个方法“fetchEntries”?
-
fetchEntries 在 initWithStyle 中被调用: