Search code examples
objective-cxmlrss-reader

Objective-C RSS Reader - XML reading error


I am new to obj-C and i'm trying to make an easy RSS Reader. It works with an external RSS file but not when i load the same file in my server based on AWS services.

This is the snippet code:

[super viewDidLoad];
feeds = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:@"http://images.apple.com/main/rss/hotnews/hotnews.rss"];
parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[parser setDelegate:self];
[parser setShouldResolveExternalEntities:NO];
[parser parse];

If i read that rss via web, i see this: original file

When I upload that file on my server, i see this: uploaded file

I tried to avoid manual upload via Filezilla but using wget command and i also tried ascii mode transfer, but still not work. RSS Reader show an empty list.


Solution

  • It is the problem with URL. I had the crash with the same code with error

    Unable to read data
    

    I replaced code with

    feedURL = NSURL(string:"http://images.apple.com/main/rss/hotnews/hotnews.rss#sthash.fuVEonEt.dpuf")!
    parser = XMLParser(contentsOf:feedURL as URL)!
    parser.delegate = self
    parser.parse()
    

    It work fine now.