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
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
20 changes: 10 additions & 10 deletions SwiftRSS/RSSFeed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 14 additions & 14 deletions SwiftRSS/RSSItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -81,8 +81,8 @@ class RSSItem: NSObject, NSCoding {
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
14 changes: 8 additions & 6 deletions SwiftRSS/RSSParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class RSSParser: NSObject, NSXMLParserDelegate {

func parserDidEndDocument(parser: NSXMLParser)
{
if let closure = self.callbackClosure?
if let closure = self.callbackClosure
{
closure(feed: self.feed, error: nil)
}
Expand All @@ -90,7 +90,7 @@ class RSSParser: NSObject, NSXMLParserDelegate {

if elementName == node_item
{
if let item = self.currentItem?
if let item = self.currentItem
{
self.feed.items.append(item)
}
Expand All @@ -99,7 +99,7 @@ class RSSParser: NSObject, NSXMLParserDelegate {
return
}

if let item = self.currentItem?
if let item = self.currentItem
{
if elementName == node_title
{
Expand Down Expand Up @@ -196,13 +196,15 @@ class RSSParser: NSObject, NSXMLParserDelegate {
}
}

func parser(parser: NSXMLParser, foundCharacters string: String) {
self.currentElement += string
func parser(parser: NSXMLParser, foundCharacters string: String?) {
if let str = string {
self.currentElement += str
}
}

func parser(parser: NSXMLParser, parseErrorOccurred parseError: NSError) {

if let closure = self.callbackClosure?
if let closure = self.callbackClosure
{
closure(feed: nil, error: parseError)
}
Expand Down
2 changes: 1 addition & 1 deletion SwiftRSS/String+imageLinksFromHTML.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension String {

var error: NSError?

var full_range: NSRange = NSMakeRange(0, countElements(self))
var full_range: NSRange = NSMakeRange(0, count(self))

if let regex = NSRegularExpression(pattern:"(https?)\\S*(png|jpg|jpeg|gif)", options:.CaseInsensitive, error:&error)
{
Expand Down
4 changes: 2 additions & 2 deletions SwiftRSS_Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
let splitViewController = self.window!.rootViewController as UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as UINavigationController
let splitViewController = self.window!.rootViewController as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
splitViewController.delegate = self
return true
Expand Down
18 changes: 9 additions & 9 deletions SwiftRSS_Example/DetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,43 @@ class DetailViewController: UIViewController {
if let webView = self.itemWebView
{

if let templateURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("template", ofType: "html")!)?
if let templateURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("template", ofType: "html")!)
{
if var template = NSString(contentsOfURL: templateURL, encoding: NSUTF8StringEncoding, error: nil)?
if var template = NSString(contentsOfURL: templateURL, encoding: NSUTF8StringEncoding, error: nil)
{
if let title = item.title?
if let title = item.title
{
template = template.stringByReplacingOccurrencesOfString("###TITLE###", withString: title)
}

if let content = item.content?
if let content = item.content
{
template = template.stringByReplacingOccurrencesOfString("###CONTENT###", withString: content)
}
else if let description = item.itemDescription?
else if let description = item.itemDescription
{
template = template.stringByReplacingOccurrencesOfString("###CONTENT###", withString: description)
}

if let date = item.pubDate?
if let date = item.pubDate
{
var formatter = NSDateFormatter()
formatter.dateFormat = "MMM dd, yyyy"

template = template.stringByReplacingOccurrencesOfString("###DATE###", withString: formatter.stringFromDate(date))
}

webView.loadHTMLString(template, baseURL: nil)
webView.loadHTMLString(template as String, baseURL: nil)
}

}
else
{
if let content = item.content?
if let content = item.content
{
webView.loadHTMLString(content, baseURL: nil)
}
else if let description = item.itemDescription?
else if let description = item.itemDescription
{
webView.loadHTMLString(description, baseURL: nil)
}
Expand Down
Loading