2

我正在开发一个项目,该项目为每篇文章的标题、描述和链接解析一个 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);
});

}

真诚感谢任何帮助。

4

1 回答 1

1

您只需附加参数如下:

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

现在使用 modifiedUrl 代替item.link

于 2013-06-26T04:08:01.320 回答