无法在我的iOS应用目标c代码中显示来自rss feed的项目标签?

时间:2014-06-15 20:31:47

标签: ios rss

我正在使用rss feed构建一个自我使用的占星应用程序。我选择的RSS提要定期更新并显示所有占星。我想展示星座的名字然后再详细说明。 我正在使用来自http://my.horoscope.com/astrology/daily-horoscopes-rss.html的Feed。 我的代码只显示描述,但不显示rss的标题。我希望它首先显示星名,当用户按下所需的星号时,它会打开其详细信息。这是代码:

    -(void)fetchRssWithURL:(NSURL*)url complete:(RSSLoaderCompleteBlock)callbackFunction
    {
    // Create url connection and fire request
    NSURLConnection *conn = [[NSURLConnection alloc] init];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    (void)[conn initWithRequest:request delegate:self];

    NSOperationQueue *queue = [[NSOperationQueue alloc] init];

    [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
           {
                   NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
                   if ([data length] == 0 && error == nil) {
                           // handle empty response
                       } else if (error != nil) {
                               // handle error
                               NSLog(@"Error %@", [error localizedDescription]);
                           } else if ([httpResponse statusCode] == 200) {
                                   RXMLElement *rss = [RXMLElement elementFromXMLData:data];
                                   RXMLElement *rssChild = [rss child:@"channel"];
                                   RXMLElement* title = [rssChild 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]];
                                           if (item.link != NULL) {
                                                   [result addObject: item];
                                               }
                                       }

                                   callbackFunction([title text], result);
                               }
               }];

    }

请帮忙吗?

0 个答案:

没有答案