Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ SwiftRSS is a simple RSS parser written in Swift.
- [x] Handle Comment link, feed and count (specific to Wordpress)
- [x] Add images helper (an array of images URL like for BlockRSSParser)
- [x] Continuous integration
- [ ] Cocoapods spec (waiting for Cocoapods Swift support)
- [x] Cocoapods spec

## Installation

The project will be available as a Pod as soon as Cocoapods will release the Swift support.
- Using [CocoaPods](https://cocoapods.org/?q=swiftrss), just add this line to your Podfile:

For now you can install this module manualy : Copy the content of the SwiftRSS folder and add it to your project.
`pod 'SwiftRSS', '~> 0.0'`

You can also use this project as Git [submodule](http://git-scm.com/docs/git-submodule).
- Installing this module manualy : Copy the content of the SwiftRSS folder and add it to your project.

- You can also use this project as Git [submodule](http://git-scm.com/docs/git-submodule).

## Usage

Expand Down
22 changes: 11 additions & 11 deletions SwiftRSS/NSDate+dateFromInternetDateTimeString.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,28 @@ extension NSDate {
{
NSDate.internetDateFormatter.dateFormat = "EEE, d MMM yyyy HH:mm:ss zzz"

date = NSDate.internetDateFormatter.dateFromString(rfc822_string)
date = NSDate.internetDateFormatter.dateFromString(rfc822_string as String)
}

if date == nil
{
NSDate.internetDateFormatter.dateFormat = "EEE, d MMM yyyy HH:mm zzz"

date = NSDate.internetDateFormatter.dateFromString(rfc822_string)
date = NSDate.internetDateFormatter.dateFromString(rfc822_string as String)
}

if date == nil
{
NSDate.internetDateFormatter.dateFormat = "EEE, d MMM yyyy HH:mm:ss"

date = NSDate.internetDateFormatter.dateFromString(rfc822_string)
date = NSDate.internetDateFormatter.dateFromString(rfc822_string as String)
}

if date == nil
{
NSDate.internetDateFormatter.dateFormat = "EEE, d MMM yyyy HH:mm"

date = NSDate.internetDateFormatter.dateFromString(rfc822_string)
date = NSDate.internetDateFormatter.dateFromString(rfc822_string as String)
}
}
else
Expand All @@ -86,28 +86,28 @@ extension NSDate {
{
NSDate.internetDateFormatter.dateFormat = "d MMM yyyy HH:mm:ss zzz"

date = NSDate.internetDateFormatter.dateFromString(rfc822_string)
date = NSDate.internetDateFormatter.dateFromString(rfc822_string as String)
}

if date == nil
{
NSDate.internetDateFormatter.dateFormat = "d MMM yyyy HH:mm zzz"

date = NSDate.internetDateFormatter.dateFromString(rfc822_string)
date = NSDate.internetDateFormatter.dateFromString(rfc822_string as String)
}

if date == nil
{
NSDate.internetDateFormatter.dateFormat = "d MMM yyyy HH:mm:ss"

date = NSDate.internetDateFormatter.dateFromString(rfc822_string)
date = NSDate.internetDateFormatter.dateFromString(rfc822_string as String)
}

if date == nil
{
NSDate.internetDateFormatter.dateFormat = "d MMM yyyy HH:mm"

date = NSDate.internetDateFormatter.dateFromString(rfc822_string)
date = NSDate.internetDateFormatter.dateFromString(rfc822_string as String)
}
}

Expand All @@ -134,21 +134,21 @@ extension NSDate {
{
NSDate.internetDateFormatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZ"

date = NSDate.internetDateFormatter.dateFromString(rfc3339_string)
date = NSDate.internetDateFormatter.dateFromString(rfc3339_string as String)
}

if date == nil // this case may need more work
{
NSDate.internetDateFormatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSSZZZ"

date = NSDate.internetDateFormatter.dateFromString(rfc3339_string)
date = NSDate.internetDateFormatter.dateFromString(rfc3339_string as String)
}

if date == nil
{
NSDate.internetDateFormatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"

date = NSDate.internetDateFormatter.dateFromString(rfc3339_string)
date = NSDate.internetDateFormatter.dateFromString(rfc3339_string as String)
}

if date == nil
Expand Down
48 changes: 24 additions & 24 deletions SwiftRSS/RSSFeed.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@

import UIKit

class RSSFeed: NSObject, NSCoding {
public class RSSFeed: NSObject, NSCoding {

var items: [RSSItem]! = [RSSItem]()
public var items: [RSSItem]! = [RSSItem]()

var title: String?
var link: NSURL?
public var title: String?
public var link: NSURL?

func setLink(let linkString: String!)
public func setLinkAsSTring(let linkString: String!)
{
link = NSURL(string: linkString)
}

var feedDescription: String?
var language: String?
var lastBuildDate: NSDate?
public var feedDescription: String?
public var language: String?
public var lastBuildDate: NSDate?

func setlastBuildDate(let dateString: String!)
public func setlastBuildDate(let dateString: String!)
{
lastBuildDate = NSDate.dateFromInternetDateTimeString(dateString)
}

var generator: String?
var copyright: String?
public var generator: String?
public var copyright: String?


override init()
public override init()
{
super.init()
}

// MARK: NSCoding
required init(coder aDecoder: NSCoder)
public required init?(coder aDecoder: NSCoder)
{
super.init()

Expand All @@ -48,46 +48,46 @@ class RSSFeed: NSObject, NSCoding {
feedDescription = aDecoder.decodeObjectForKey("description") as? String
language = aDecoder.decodeObjectForKey("language") as? String
lastBuildDate = aDecoder.decodeObjectForKey("lastBuildDate") as? NSDate
generator = aDecoder.decodeObjectForKey("generator") as? NSString
copyright = aDecoder.decodeObjectForKey("copyright") as? NSString
generator = aDecoder.decodeObjectForKey("generator") as? String
copyright = aDecoder.decodeObjectForKey("copyright") as? String

items = aDecoder.decodeObjectForKey("items") as [RSSItem]
items = aDecoder.decodeObjectForKey("items") as! [RSSItem]
}

func encodeWithCoder(aCoder: NSCoder)
public func encodeWithCoder(aCoder: NSCoder)
{
if let title = self.title?
if let title = self.title
{
aCoder.encodeObject(title, forKey: "title")
}

if let link = self.link?
if let link = self.link
{
aCoder.encodeObject(link, forKey: "link")
}

if let feedDescription = self.feedDescription?
if let feedDescription = self.feedDescription
{
aCoder.encodeObject(feedDescription, forKey: "description")
}

if let language = self.language?
if let language = self.language
{
aCoder.encodeObject(language, forKey: "language")
}

if let lastBuildDate = self.lastBuildDate?
if let lastBuildDate = self.lastBuildDate
{
aCoder.encodeObject(lastBuildDate, forKey: "lastBuildDate")
}

if let generator = self.generator?
if let generator = self.generator
{
aCoder.encodeObject(generator, forKey: "generator")
}


if let copyright = self.copyright?
if let copyright = self.copyright
{
aCoder.encodeObject(copyright, forKey: "copyright")
}
Expand Down
70 changes: 35 additions & 35 deletions SwiftRSS/RSSItem.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,136 +8,136 @@

import UIKit

class RSSItem: NSObject, NSCoding {
var title: String?
var link: NSURL?
public class RSSItem: NSObject, NSCoding {
public var title: String?
public var link: NSURL?

func setLink(let linkString: String!)
public func setLinkAsString(let linkString: String!)
{
link = NSURL(string: linkString)
}

var guid: String?
var pubDate: NSDate?
public var guid: String?
public var pubDate: NSDate?

func setPubDate(let dateString: String!)
public func setPubDateAsString(let dateString: String!)
{
pubDate = NSDate.dateFromInternetDateTimeString(dateString)
}

var itemDescription: String?
var content: String?
public var itemDescription: String?
public var content: String?

// Wordpress specifics
var commentsLink: NSURL?
public var commentsLink: NSURL?

func setCommentsLink(let linkString: String!)
public func setCommentsLinkAsString(let linkString: String!)
{
commentsLink = NSURL(string: linkString)
}

var commentsCount: Int?
public var commentsCount: Int?

var commentRSSLink: NSURL?
public var commentRSSLink: NSURL?

func setCommentRSSLink(let linkString: String!)
public func setCommentRSSLinkAsString(let linkString: String!)
{
commentRSSLink = NSURL(string: linkString)
}

var author: String?
public var author: String?

var categories: [String]! = [String]()
public var categories: [String]! = [String]()

var imagesFromItemDescription: [NSURL]! {
if let itemDescription = self.itemDescription?
public var imagesFromItemDescription: [NSURL]! {
if let itemDescription = self.itemDescription
{
return itemDescription.imageLinksFromHTMLString
}

return [NSURL]()
}

var imagesFromContent: [NSURL]! {
if let content = self.content?
public var imagesFromContent: [NSURL]! {
if let content = self.content
{
return content.imageLinksFromHTMLString
}

return [NSURL]()
}

override init()
public override init()
{
super.init()
}

// MARK: NSCoding
required init(coder aDecoder: NSCoder)
public required init?(coder aDecoder: NSCoder)
{
super.init()

title = aDecoder.decodeObjectForKey("title") as? String
link = aDecoder.decodeObjectForKey("link") as? NSURL
guid = aDecoder.decodeObjectForKey("guid") as? String
pubDate = aDecoder.decodeObjectForKey("pubDate") as? NSDate
itemDescription = aDecoder.decodeObjectForKey("description") as? NSString
content = aDecoder.decodeObjectForKey("content") as? NSString
itemDescription = aDecoder.decodeObjectForKey("description") as? String
content = aDecoder.decodeObjectForKey("content") as? String
commentsLink = aDecoder.decodeObjectForKey("commentsLink") as? NSURL
commentsCount = aDecoder.decodeObjectForKey("commentsCount") as? Int
commentRSSLink = aDecoder.decodeObjectForKey("commentRSSLink") as? NSURL
author = aDecoder.decodeObjectForKey("author") as? String
categories = aDecoder.decodeObjectForKey("categories") as? [String]
}

func encodeWithCoder(aCoder: NSCoder)
public func encodeWithCoder(aCoder: NSCoder)
{
if let title = self.title?
if let title = self.title
{
aCoder.encodeObject(title, forKey: "title")
}

if let link = self.link?
if let link = self.link
{
aCoder.encodeObject(link, forKey: "link")
}

if let guid = self.guid?
if let guid = self.guid
{
aCoder.encodeObject(guid, forKey: "guid")
}

if let pubDate = self.pubDate?
if let pubDate = self.pubDate
{
aCoder.encodeObject(pubDate, forKey: "pubDate")
}

if let itemDescription = self.itemDescription?
if let itemDescription = self.itemDescription
{
aCoder.encodeObject(itemDescription, forKey: "description")
}

if let content = self.content?
if let content = self.content
{
aCoder.encodeObject(content, forKey: "content")
}

if let commentsLink = self.commentsLink?
if let commentsLink = self.commentsLink
{
aCoder.encodeObject(commentsLink, forKey: "commentsLink")
}

if let commentsCount = self.commentsCount?
if let commentsCount = self.commentsCount
{
aCoder.encodeObject(commentsCount, forKey: "commentsCount")
}

if let commentRSSLink = self.commentRSSLink?
if let commentRSSLink = self.commentRSSLink
{
aCoder.encodeObject(commentRSSLink, forKey: "commentRSSLink")
}

if let author = self.author?
if let author = self.author
{
aCoder.encodeObject(author, forKey: "author")
}
Expand Down
Loading