开发者

iPhone - dataWithContentsOfURL: does not work for some URLs

开发者 https://www.devze.com 2022-12-12 19:47 出处:网络
I am using NSData to get content from a URL (RSS feed) and then parse it. While most of the URLs are loaded fine, some of them don\'t return any data.

I am using NSData to get content from a URL (RSS feed) and then parse it. While most of the URLs are loaded fine, some of them don't return any data.

These URLs open on the web so I know they are valid, but they just don't return any NSData. One such URL - feed://jpl.nasa.gov/multimedia/rss/rovers.xml

Here's how I am using it (the NSURL object is formed properly)

NSURL *feedURL = [NSURL URLWithString:[myUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSData *data = [NSData dataWithContentsOfURL:feedURL开发者_JS百科];

Any ideas why?

Thanks a lot.


Switch to NSURLConnection so you have some delegate methods to watch what's happening in debugger. check out the URL Loading System docs if you haven't.

0

精彩评论

暂无评论...
验证码 换一张
取 消