Rss reads iphone / ipad application

I have an error reading XML files for my iPhone application. I have a new feature in an iPhone app that reads my RSS feed. Everything looks good, but I have this problem:

Error loading rss. Check your internet connection.

Here is my code:

- (BOOL) readRSS { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; [[NSURLCache sharedURLCache] setMemoryCapacity:0]; [[NSURLCache sharedURLCache] setDiskCapacity:0]; BOOL success = NO; NSXMLParser *parser = nil; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://rss.domain.com/%@.xml", self.currentPage]]; parser = [[NSXMLParser alloc] initWithContentsOfURL:url]; [parser setDelegate:self]; [parser setShouldProcessNamespaces:NO]; [parser setShouldReportNamespacePrefixes:NO]; [parser setShouldResolveExternalEntities:NO]; success = [parser parse]; [parser release]; [pool drain]; return success; } 

Then I have this code:

 - (void) cleartbl:(NSInteger)type { [[[self rssParser] rssItems] removeAllObjects]; [_tableView reloadData]; if(type == 1) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"RSS Feed" message:@"Error while loading rss. Please check your Internet connection." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; [alert release]; } 

Then I assign:

 if([elementName isEqualToString:@"title"]){ self.currentItem.title = self.currentItemValue; } 

What is my problem, am I missing something?

+6
source share
1 answer

The code presented looks good to me, I would be the first to do to check if your RSS is valid. I think you have a problem with RSS here. You can use RSS Validation to make sure everything looks good.

I would recommend misinforming your RSS, saving it is very simple if you want to display news or articles using letters and numbers in the text and use URLs that are SEO friendly.

This will simplify the data that you download from your application, and avoid errors such as special characters.

Try simple single post RSS to get started and you will see if your code has errors.

+12
source

Source: https://habr.com/ru/post/904047/


All Articles