Latest 0.2.1
Homepage https://github.com/thecatalinstan/CSFeedKit
License MIT
Platforms osx 10.8, requires ARC
Authors

Version Status Platform Carthage compatible MIT License

An RSS feed generator and parser for macOS. Swift and Objective-C compatible.

Installation

Install using CocoaPods by adding this line to your Podfile:

use_frameworks!

target 'MyApp' do
  pod 'CSFeedKit'
end

Creating an RSS Feed

The example below creates an RSS feed and prints the resulting XML string.


// Create a channel
let channel = CSRSSFeedChannel.init(title: "My RSS feed", link: "http://my.rss.feed/", description: "My first CSFeedKit RSS feed")
channel.category = "Examples"

// Add an item to the channel
let item = CSRSSFeedItem(title: "Item" , link: "http://my.rss.feed/item", description: "The coolest item so far.");
item1.creator = NSFullUserName()
channel.items.addObject(item)

// Create the feed
let feed = CSRSSFeed()

// Add the channel to the feed
feed.channels.addObject(channel)

// Output the XML
print ( feed.XMLDocument().XMLStringWithOptions(NSXMLNodePrettyPrint))

Parsing an RSS feed

The following prints out the titles and URLs of the items in the Hacker News RSS feed.

do {
    // Get the XML string (don't do it like this in the real-world ;) )
    let xmlString = try NSString.init(contentsOfURL: NSURL(string: "https://news.ycombinator.com/rss")!, encoding: NSUTF8StringEncoding)

    // Init the feed
    let feed = try CSRSSFeed.init(XMLString: xmlString as String)

    // Print channel info
    let channel = feed.channels.firstObject as! CSRSSFeedChannel
    print("channel: (channel.title)")

    // Print the items
    for (_, item) in channel.items.enumerate() {
        var rssItem = item as! CSRSSFeedItem
        print(" * (rssItem.pubDate) - (rssItem.title) ((rssItem.link))")
    }
} catch {
    print(error)
}

What’s Next

Run the built-in example: https://github.com/thecatalinstan/CSFeedKit/blob/master/CSFeedKitExamples/CSFeedKitExamples/main.swift

Check out the complete documentation on CocoaDocs.

Latest podspec

{
    "name": "CSFeedKit",
    "version": "0.2.1",
    "license": "MIT",
    "summary": "An RSS feed generator and parser for macOS. Swift and Objective-C compatible.",
    "homepage": "https://github.com/thecatalinstan/CSFeedKit",
    "authors": {
        "Cu0103tu0103lin Stan": "[email protected]"
    },
    "social_media_url": "http://twitter.com/catalinstan",
    "source": {
        "git": "https://github.com/thecatalinstan/CSFeedKit.git",
        "tag": "0.2.1"
    },
    "module_name": "CSFeedKit",
    "source_files": [
        "CSFeedKit/*.{h,m}",
        "CSFeedKit/RSS/*.{h,m}"
    ],
    "public_header_files": [
        "CSFeedKit/CSFeedKit.h",
        "CSFeedKit/CSFeed.h",
        "CSFeedKit/CSFeedChannel.h",
        "CSFeedKit/CSFeedItem.h",
        "CSFeedKit/RSS/CSRSSFeed.h",
        "CSFeedKit/RSS/CSRSSFeedChannel.h",
        "CSFeedKit/RSS/CSRSSFeedItem.h"
    ],
    "platforms": {
        "osx": "10.8"
    },
    "osx": {
        "frameworks": "Foundation"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This