我正在开发一个项目,该项目为每篇文章的标题、描述和链接解析一个 rss 提要。然后我需要在链接后面附加一个字符串 @"?f=m"
我很难弄清楚从哪里开始。我是IOS编程的新手。我认为我需要操作的文件在这里:
-(void)viewDidAppearBOOL)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)fetchRssWithURLNSURL*)url completeRSSLoaderCompleteBlock)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);
});
}
真诚感谢任何帮助。
Best Answer-推荐答案 strong>
您只需将参数附加如下:
NSString *modifiedString = [NSString stringWithFormat"%@%@",[item.link absoluteString],@"?f=m"];
NSURL *modifiedUrl = [NSURL URLWithString:modifiedString];
现在使用 modifiedUrl 代替 item.link
关于ios - 解析 rss 提要并将字符串附加到链接 - objective-c ,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/17310966/
|