0

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.

Otto
  • 119
  • 3
  • 12
  • I don't know if it's related to AWS or Objective-C. But what you could do it read the two as NSString, and check if there are some differences. Also, are both pages ending with `.rss`? – Larme Oct 05 '16 at 10:10
  • Both pages ending with `.rss`. I used the same file from Apple.com. The original one works on my app, while the same file uploaded in my server not work :( – Otto Oct 05 '16 at 10:19
  • What's the error? Is `url` nil on the AWS's page? – Larme Oct 05 '16 at 11:23
  • RSS reader doesn't read the rss file on my server. I discovered many seconds ago the error is my server doesn't have https:// ... i've temporary place the file on the another server with ssl certificate and it works. In general xml parser can't read file from http domain? – Otto Oct 05 '16 at 11:41
  • App Transport Security Issue? http://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled-in-ios-9 – Larme Oct 05 '16 at 11:42
  • Yay! Now It works! Thaaaank you!!!! :) – Otto Oct 06 '16 at 08:02

2 Answers2

1

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.

Forte Zhu
  • 742
  • 3
  • 12
  • 33
0

As suggested by @Larme, it was the App Transport Security Issue How do I load an HTTP URL with App Transport Security enabled in iOS 9? .

This solved my issue!

Community
  • 1
  • 1
Otto
  • 119
  • 3
  • 12