Skip to content

Commit

Permalink
Update all 5 minutes and read an RSS feed
Browse files Browse the repository at this point in the history
updating via a timer every five minutes (still loving SwiftyTimer) and
using MWFeedParser to read the RSS feed at parkendd.tumblr.com. This'll
be used to display updates to the user should anything change or be
sent out.

See #76
  • Loading branch information
kiliankoe committed Jul 9, 2015
1 parent 73bde0e commit 3994f4e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions ParkenDD/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
struct Const {
static let apibaseURL = "https://park-api.higgsboson.tk/"
static let supportedAPIVersion = 1.0
static let rssURL = "http://parkendd.tumblr.com/rss"
}
31 changes: 29 additions & 2 deletions ParkenDD/LotlistViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import UIKit
import CoreLocation
//import MCSwipeTableViewCell
import TSMessages
import SwiftyTimer
import MWFeedParser

// Removing MCSwipeTableViewCellDelegate here temporarily
class LotlistViewController: UITableViewController, CLLocationManagerDelegate, UISearchBarDelegate, UISearchControllerDelegate, UISearchResultsUpdating {
class LotlistViewController: UITableViewController, CLLocationManagerDelegate, UISearchBarDelegate, UISearchControllerDelegate, UISearchResultsUpdating, MWFeedParserDelegate {

let locationManager = CLLocationManager()

Expand All @@ -26,6 +28,8 @@ class LotlistViewController: UITableViewController, CLLocationManagerDelegate, U
var timeDownloaded: NSDate?
var dataSource: String?

var feedItems = [MWFeedItem]()

override func viewDidLoad() {
super.viewDidLoad()

Expand Down Expand Up @@ -62,7 +66,15 @@ class LotlistViewController: UITableViewController, CLLocationManagerDelegate, U
// Set a table footer view so that separators aren't shown when no data is yet present
self.tableView.tableFooterView = UIView(frame: CGRectZero)

// Create Feed Parser for news notification
let rssURL = NSURL(string: Const.rssURL)
let feedParser = MWFeedParser(feedURL: rssURL)
feedParser.delegate = self
feedParser.connectionType = ConnectionTypeAsynchronously
feedParser.parse()

updateData()
NSTimer.every(5.minutes,updateData)
}

override func viewWillAppear(animated: Bool) {
Expand Down Expand Up @@ -487,7 +499,6 @@ class LotlistViewController: UITableViewController, CLLocationManagerDelegate, U
// /////////////////////////////////////////////////////////////////////////
// MARK: - CLLocationManagerDelegate
// /////////////////////////////////////////////////////////////////////////

func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) {
let currentLocation: CLLocation = locations.last as! CLLocation

Expand Down Expand Up @@ -559,4 +570,20 @@ class LotlistViewController: UITableViewController, CLLocationManagerDelegate, U
return imageView
}

// /////////////////////////////////////////////////////////////////////////
// MARK: - MWFeedParser
// /////////////////////////////////////////////////////////////////////////

func feedParser(parser: MWFeedParser!, didParseFeedItem item: MWFeedItem!) {
self.feedItems.append(item)
}

func feedParserDidFinish(parser: MWFeedParser!) {
let lastItem = self.feedItems.first
let request = NSURLRequest(URL: NSURL(string: lastItem!.link)!)

// TODO: Display a modal VC with the post page of the latest post
// Some kind of check for which notifications have been displayed needs to be built as well
}

}
2 changes: 2 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ pod 'BEMSimpleLineGraph', '~> 3.3'
pod 'MCSwipeTableViewCell', '~> 2.1.2'
pod 'Alamofire', '~> 1.2'
pod 'SwiftyJSON', '~> 2.2'
pod 'SwiftyTimer', '~> 1.1.0'
pod 'MWFeedParser', '~> 1.0.1'
14 changes: 14 additions & 0 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,37 @@ PODS:
- BEMSimpleLineGraph (3.3)
- HexColors (2.2.1)
- MCSwipeTableViewCell (2.1.2)
- MWFeedParser (1.0.1):
- MWFeedParser/FeedParser (= 1.0.1)
- MWFeedParser/NSDate+InternetDateTime (= 1.0.1)
- MWFeedParser/NSString+HTML (= 1.0.1)
- MWFeedParser/FeedParser (1.0.1):
- MWFeedParser/NSDate+InternetDateTime
- MWFeedParser/NSString+HTML
- MWFeedParser/NSDate+InternetDateTime (1.0.1)
- MWFeedParser/NSString+HTML (1.0.1)
- SwiftyJSON (2.2.0)
- SwiftyTimer (1.1.0)
- TSMessages (0.9.12):
- HexColors

DEPENDENCIES:
- Alamofire (~> 1.2)
- BEMSimpleLineGraph (~> 3.3)
- MCSwipeTableViewCell (~> 2.1.2)
- MWFeedParser (~> 1.0.1)
- SwiftyJSON (~> 2.2)
- SwiftyTimer (~> 1.1.0)
- TSMessages (~> 0.9.12)

SPEC CHECKSUMS:
Alamofire: 5550bf0b575ed1a4bf9be572f9463e1015cc169e
BEMSimpleLineGraph: 7fc92cd65a5f91640f6624b11be96fe1f3d7f1cf
HexColors: abfd172e329dab59888614ccba6f216cec59289d
MCSwipeTableViewCell: 0fc22bd3635b9b5f4ce08675218b0a7278b6440f
MWFeedParser: 2cf646014c1baf6ad1b08c480b40a08180079247
SwiftyJSON: 0b3e6c07af17ff745e77e8e9984097b55c956e5c
SwiftyTimer: 3b1bf42c8b1bb09dff7107b12d3b73cbf700bbce
TSMessages: 2a52642128d7ab15b46930c810b9c9403a2b58f3

COCOAPODS: 0.37.2

0 comments on commit 3994f4e

Please sign in to comment.