我正在开发一个项目,用于解析每篇文章标题,描述和链接的RSS订阅源。然后我需要用字符串@“?f = m”附加链接 我无法确定从哪里开始。我是IOS编程的新手。我认为我需要操作的文件在这里:
-(void)viewDidAppear:(BOOL)animated
{
RSSItem* item = (RSSItem*)self.detailItem;
self.title = item.title;
webView.delegate = self;
NSURLRequest* articleRequest = [NSURLRequest requestWithURL: item.link];
webView.backgroundColor = [UIColor clearColor];
[webView loadRequest: articleRequest];
}
但它也可以在这里:
-(void)fetchRssWithURL:(NSURL*)url complete:(RSSLoaderCompleteBlock)c
{
dispatch_async(kBgQueue, ^{
//work in the background
RXMLElement *rss = [RXMLElement elementFromURL: url];
RXMLElement* title = [[rss child:@"channel"] child:@"title"];
NSArray* items = [[rss child:@"channel"] children:@"item"];
NSMutableArray* result = [NSMutableArray arrayWithCapacity:items.count];
//more code
for (RXMLElement *e in items) {
//iterate over the articles
RSSItem* item = [[RSSItem alloc] init];
item.title = [[e child:@"title"] text];
item.description = [[e child:@"description"] text];
item.link = [NSURL URLWithString: [[e child:@"link" ] text ]] ;
[result addObject: item];
}
c([title text], result);
});
}
真心感谢任何帮助。
答案 0 :(得分:1)
您只需将参数附加如下:
NSString *modifiedString = [NSString stringWithFormat:@"%@%@",[item.link absoluteString],@"?f=m"];
NSURL *modifiedUrl = [NSURL URLWithString:modifiedString];
现在使用modifiedUrl而不是 item.link