首页 文章

解析rss feed并将字符串附加到链接 - 目标c

提问于
浏览
2

我正在开发一个项目,为每篇文章的 Headers ,描述和链接解析rss feed . 然后我需要用字符串@“?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);
});

}

任何帮助都是真诚的感谢 .

1 回答

  • 1

    您只需将参数附加如下:

    NSString *modifiedString = [NSString stringWithFormat:@"%@%@",[item.link absoluteString],@"?f=m"];
    NSURL *modifiedUrl = [NSURL URLWithString:modifiedString];
    

    现在使用modifiedUrl而不是 item.link

相关问题