Created
September 18, 2015 14:06
-
-
Save 3lvis/9dd6688e939b13d52a0a to your computer and use it in GitHub Desktop.
Controller.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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