How to write an RSS client for iOS
Sent from my iPhone hi, what would I need in order to write my own RSS reader for iOS? I wanted to know how this was done because I am interested in all of this RSS and podcast feeds and stuff like that. What frameworks would I need to use in iOS in order to pull news articles or podcasts from the web and then played them through the app? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to write an RSS client for iOS
> On Feb 13, 2016, at 10:02 AM, nicholasacosta...@gmail.com wrote: > > > > hi, what would I need in order to write my own RSS reader for iOS? - NSURLSession to fetch feeds. - NSXMLParser to parse the feeds. (I was going to write "NSXMLDocument to parse the feeds”, but that class only exists on Mac OS, for some reason) - libTidy to clean up broken/invalid XML before parsing Now for the hard parts. I’ve implemented a feed reader in the past (the PubSub framework in OS X, which used to be used by Mail and Safari) so I’m intimately familiar with the hard parts. * Some feeds are not valid XML, so NSXMLParser will fail to parse them. (This most often happens when people put their HTML articles directly into the XML without escaping the HTML.) To work around this you will need to use libTidy, an open source library that can clean up invalid XML. (NSXMLDocument already supports tidy, but it’s not available on iOS.) * There are literally about a dozen dialects of RSS and Atom in use, from Netscape’s old RSS 0.9 up through RSS 2.0 (which comes in a couple of flavors) and Atom 1.0. (Yes, a dozen. Mark Pilgrim made a list of them once.) Some are hugely different from each other, some are just a little different. Your code that interprets the XML will have to be aware of all of them. * Once you’ve parsed the articles out of a feed, you probably need to figure out which ones are new to you, so you can highlight them or alert the user or whatever. Identifying articles varies between the dialects. Atom and RSS 2.0 have a GUID (unique ID) attribute for this, but it’s not always present. Otherwise you can treat the article’s permalink as being the unique ID, if there is one. Otherwise you have to go by the title + text. There are other “fun” details, like parsing dates — the different specs call for different date formats, and many feeds just ignore those and emit some other date format, which makes parsing them really difficult. Our code ended up with a list of about 20(!) date-format strings and tried them one after the other. It’s a total pain in the butt, to be honest. I’m not sure if there are any existing open source iOS frameworks for reading feeds, but if there is one, you’ll be much better off using it than writing your own. —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to write an RSS client for iOS
This. > It’s a total pain in the butt, to be honest. I’m not sure if there are any > existing open source iOS frameworks for reading feeds, but if there is one, > you’ll be much better off using it than writing your own. > > —Jens -Daniel smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to write an RSS client for iOS
For dates, you can try using NSDataDetector, but I’ve found recently that it doesn’t work well if you only have a date or a time, only if you have both; it adds a placeholder value in those cases and doesn’t report that you only have one or the other. In the case for RSS feeds, though, you shouldn’t have that issue unless you’re using it on content, but keep that in mind. And, if anyone else finds the same need from NSDataDetector as me, please join me in writing a bug requesting this to be fixed in the next OSes and documented how we can make some use of NSDataDetector in the current and prior versions (I have personally figured this out already, but it’s fragile and not the best or supported practice). Note that my bug has already been duplicated, probably from my initial tech support incident, and this helps get it prioritized higher. — Gary > On Feb 13, 2016, at 10:44 AM, Jens Alfkewrote: > > There are other “fun” details, like parsing dates — the different specs call > for different date formats, and many feeds just ignore those and emit some > other date format, which makes parsing them really difficult. Our code ended > up with a list of about 20(!) date-format strings and tried them one after > the other. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to write an RSS client for iOS
Cool. Hopefully it’ll be in the next release, so keep adding bug reports. I didn’t want to write another regular expression to do something the class already does and get it wrong; if I do that, I might as well not even use NSDataDetector. In case you’re curious, Xcode, while debugging some runtime environments, will give you the info that’s really useful for such result objects. — Gary > On Feb 13, 2016, at 1:18 PM, Alex Kacwrote: > > We had the same issue and what we do is we look at the data detector match > string, determine if its date or time only using several techniques including > a regex…and go from there. Its not perfect, but it works relatively well. > > We do have a radar on the need to know if it found a date or date/time. > Ideally I’d like to get NSDateComponents back from the data detector so we > know what was found. > >> On Feb 13, 2016, at 1:16 PM, Gary L. Wade >> wrote: >> >> For dates, you can try using NSDataDetector, but I’ve found recently that it >> doesn’t work well if you only have a date or a time, only if you have both; >> it adds a placeholder value in those cases and doesn’t report that you only >> have one or the other. In the case for RSS feeds, though, you shouldn’t >> have that issue unless you’re using it on content, but keep that in mind. >> >> And, if anyone else finds the same need from NSDataDetector as me, please >> join me in writing a bug requesting this to be fixed in the next OSes and >> documented how we can make some use of NSDataDetector in the current and >> prior versions (I have personally figured this out already, but it’s fragile >> and not the best or supported practice). Note that my bug has already been >> duplicated, probably from my initial tech support incident, and this helps >> get it prioritized higher. >> — > > > Alex Kac - El capitán > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com