Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated the SwiftRSS to Swift 2.0 #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
22 changes: 11 additions & 11 deletions SwiftRSS/NSDate+dateFromInternetDateTimeString.swift
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
26 changes: 13 additions & 13 deletions SwiftRSS/RSSFeed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RSSFeed: NSObject, NSCoding {
var title: String?
var link: NSURL?

func setLink(let linkString: String!)
func setLinkAsString(let linkString: String!)
{
link = NSURL(string: linkString)
}
Expand All @@ -39,7 +39,7 @@ class RSSFeed: NSObject, NSCoding {
}

// MARK: NSCoding
required init(coder aDecoder: NSCoder)
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)
{
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
42 changes: 21 additions & 21 deletions SwiftRSS/RSSItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class RSSItem: NSObject, NSCoding {
var title: String?
var link: NSURL?

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

var guid: String?
var pubDate: NSDate?

func setPubDate(let dateString: String!)
func setPubDateAsString(let dateString: String!)
{
pubDate = NSDate.dateFromInternetDateTimeString(dateString)
}
Expand All @@ -31,7 +31,7 @@ class RSSItem: NSObject, NSCoding {
// Wordpress specifics
var commentsLink: NSURL?

func setCommentsLink(let linkString: String!)
func setCommentsLinkAsString(let linkString: String!)
{
commentsLink = NSURL(string: linkString)
}
Expand All @@ -40,7 +40,7 @@ class RSSItem: NSObject, NSCoding {

var commentRSSLink: NSURL?

func setCommentRSSLink(let linkString: String!)
func setCommentRSSLinkAsString(let linkString: String!)
{
commentRSSLink = NSURL(string: linkString)
}
Expand All @@ -50,7 +50,7 @@ class RSSItem: NSObject, NSCoding {
var categories: [String]! = [String]()

var imagesFromItemDescription: [NSURL]! {
if let itemDescription = self.itemDescription?
if let itemDescription = self.itemDescription
{
return itemDescription.imageLinksFromHTMLString
}
Expand All @@ -59,7 +59,7 @@ class RSSItem: NSObject, NSCoding {
}

var imagesFromContent: [NSURL]! {
if let content = self.content?
if let content = self.content
{
return content.imageLinksFromHTMLString
}
Expand All @@ -73,16 +73,16 @@ class RSSItem: NSObject, NSCoding {
}

// MARK: NSCoding
required init(coder aDecoder: NSCoder)
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
Expand All @@ -92,52 +92,52 @@ class RSSItem: NSObject, NSCoding {

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