How would I make an NSTableView display an RSS Feed (just one)? I think it would have something to do with NSURL and Setting the Table Views Data Source. But how exactly would I do this?
There are a couple of steps to this.
- You need a datasource, of course.
- This datasource needs to be capable of either itself attaching to an RSS feed, reading it, parsing it and turning it into something sensible for display; or:
- You need to have a datasource-datasource that encapsulates the network/XML parsing/RSS interpreting bits.
Most likely you'll want something like:
NSTableView <-> MyDatasource <-> MyDownloadHandler
Where MyDownloadHandler
takes care of all the downloading and parsing, and notifies MyDatasource
as it receives data, which then notifies the table view to redraw itself (or patiently waits for the table view to redraw itself in the course of its normal operations or as the result of a timer firing, or by emitting notifications captured by a controller that asks the table view to redraw itself).
EDIT: This, of course, doesn't actually answer your question...
Specifically you will need an NSURLConnection object to get the RSS feed (either synchronously or async; it can do both if memory serves, if not, there's another class that does.)
You will also need to implement the NSXMLParserDelegate
category on a handler object and run an NSXMLParser
on your RSS feed. (NSXMLParser
can in fact be initialized directly with initWithContentsOfURL:
, potentially saving you some time.)
You should take a look at the PubSub.framework:
Apple Developer Connection PubSub Programming Guide
Some features:
- retrieve feed contents
- subscribe to feeds
- Atom/RSS agnostic
- ...
10.5+ only