Skip to content

Instantly share code, notes, and snippets.

@3lvis
Created September 18, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3lvis/9dd6688e939b13d52a0a to your computer and use it in GitHub Desktop.
Save 3lvis/9dd6688e939b13d52a0a to your computer and use it in GitHub Desktop.
Controller.swift
import UIKit
import DATASource
class SlotsController: UITableViewController {
var networking: NetworkingClient
// MARK - Getters
lazy var dataSource: DATASource = {
let dataSource = DATASource(tableView: self.tableView, fetchRequest: Slot.request(), sectionName: nil, cellIdentifier: SlotCell.Identifier, mainContext: self.networking.data.mainContext, configuration: { cell, item, indexPath in
if let cell = cell as? SlotCell, item = item as? Slot {
cell.slot = item
}
})
return dataSource
}()
// MARK: - Initializers
init(networking: NetworkingClient) {
self.networking = networking
super.init(nibName: nil, bundle: nil)
}
required init!(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.dataSource = self.dataSource
self.tableView.registerClass(SlotCell.self, forCellReuseIdentifier: SlotCell.Identifier)
self.networking.slots { (error) -> () in
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment