Use check-in table view controller as base view controller for training check-in table view controller

This commit is contained in:
Raimund Wege
2017-09-07 16:25:20 +02:00
parent 659d7aa94b
commit a74457df8e
3 changed files with 48 additions and 122 deletions
@@ -39,7 +39,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
</imageView>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="81" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="OXU-ft-TXZ">
<rect key="frame" x="0.0" y="0.0" width="375" height="400.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="397.5"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<view key="tableHeaderView" contentMode="scaleToFill" id="mhw-sY-eah" userLabel="Header View">
<rect key="frame" x="0.0" y="0.0" width="375" height="52"/>
@@ -89,7 +89,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Event Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Xi-He-o21">
<rect key="frame" x="20" y="8" width="140.5" height="25"/>
<rect key="frame" x="20" y="8" width="135" height="21"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="etP-MF-gtd"/>
</constraints>
@@ -98,7 +98,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Competitor Label" textAlignment="right" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sNr-Dr-sM5">
<rect key="frame" x="168.5" y="8" width="186.5" height="64"/>
<rect key="frame" x="163" y="8" width="192" height="64"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="tpS-bc-kNc"/>
</constraints>
@@ -107,7 +107,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Leaderboard Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yqN-BN-c2a">
<rect key="frame" x="20" y="41" width="140.5" height="31"/>
<rect key="frame" x="20" y="37" width="135" height="35"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="O6Y-JP-Mx0"/>
</constraints>
@@ -143,7 +143,7 @@
</connections>
</tableView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kz1-Nl-j1h" userLabel="Button View" customClass="GradientView" customModule="SAPTracker" customModuleProvider="target">
<rect key="frame" x="0.0" y="400.5" width="375" height="202.5"/>
<rect key="frame" x="0.0" y="397.5" width="375" height="205.5"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ieu-ch-jeI">
<rect key="frame" x="20" y="20" width="335" height="82"/>
@@ -198,7 +198,7 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Info Code Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="OqX-q3-43s">
<rect key="frame" x="20" y="166" width="335" height="16.5"/>
<rect key="frame" x="20" y="166" width="335" height="19.5"/>
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="14"/>
<nil key="highlightedColor"/>
</label>
@@ -318,7 +318,7 @@
<scene sceneID="e3W-CJ-soQ">
<objects>
<navigationController storyboardIdentifier="rootViewController" id="pqQ-jd-OwW" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="x3H-m5-yJB">
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="x3H-m5-yJB">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
@@ -801,7 +801,8 @@
</navigationItem>
<connections>
<outlet property="addButton" destination="Pwd-JR-SVL" id="oQ2-6e-NCD"/>
<outlet property="footerTextView" destination="AW1-r0-JWj" id="BoM-tz-fRo"/>
<outlet property="footerTextView" destination="AW1-r0-JWj" id="LsL-zZ-u9a"/>
<outlet property="footerView" destination="wnC-wX-KjK" id="g1t-pW-6KE"/>
<outlet property="headerTitleLabel" destination="bx9-EY-ljk" id="91C-Q7-cME"/>
<outlet property="headerView" destination="Ugq-RP-elj" id="W6j-cd-AzM"/>
<outlet property="tableView" destination="bav-TA-AP5" id="MUP-iZ-LeY"/>
@@ -849,7 +850,7 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Mark Name Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="12" adjustsLetterSpacingToFitWidth="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="BQe-Id-ec3">
<rect key="frame" x="105" y="290.5" width="166.5" height="22"/>
<rect key="frame" x="101.5" y="290.5" width="173" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="g3A-7J-yFy"/>
</constraints>
@@ -917,19 +918,19 @@
<rect key="frame" x="0.0" y="272" width="375" height="38"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sail ID Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="iIf-9z-7fe">
<rect key="frame" x="265.5" y="10" width="89.5" height="19"/>
<rect key="frame" x="258" y="8.5" width="97" height="22"/>
<fontDescription key="fontDescription" name="OpenSans-Bold" family="Open Sans" pointSize="16"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="DE.png" translatesAutoresizingMaskIntoConstraints="NO" id="szG-Mg-huO">
<rect key="frame" x="233.5" y="7" width="24" height="24"/>
<rect key="frame" x="226" y="7" width="24" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="Ina-uK-atY"/>
<constraint firstAttribute="height" constant="24" id="TVX-WF-dOi"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Competitor Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="oJS-dM-2B6" userLabel="Name Label">
<rect key="frame" x="20" y="10" width="124.5" height="19"/>
<rect key="frame" x="20" y="8.5" width="139" height="22"/>
<fontDescription key="fontDescription" name="OpenSans-Bold" family="Open Sans" pointSize="16"/>
<nil key="highlightedColor"/>
</label>
@@ -988,7 +989,7 @@
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="1" verticalHuggingPriority="1" horizontalCompressionResistancePriority="999" verticalCompressionResistancePriority="999" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="clip" translatesAutoresizingMaskIntoConstraints="NO" id="CDA-ep-bjo">
<rect key="frame" x="70" y="116" width="235" height="40"/>
<rect key="frame" x="66" y="115.5" width="243" height="41"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="18"/>
<inset key="contentEdgeInsets" minX="8" minY="8" maxX="8" maxY="8"/>
@@ -1055,24 +1056,24 @@
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6rV-hv-c3D" userLabel="Countdown View">
<rect key="frame" x="13" y="38" width="349.5" height="50"/>
<rect key="frame" x="6" y="38" width="363" height="50"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pjH-rV-MGI" userLabel="Days View">
<rect key="frame" x="0.0" y="0.0" width="116.5" height="50"/>
<rect key="frame" x="0.0" y="0.0" width="121" height="50"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="356" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sGD-0U-P4b">
<rect key="frame" x="8" y="0.0" width="99.5" height="24.5"/>
<rect key="frame" x="8" y="0.0" width="104" height="29"/>
<fontDescription key="fontDescription" name="OpenSans-Semibold" family="Open Sans" pointSize="21"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Days Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l8F-Sg-cUb" userLabel="Days Description Label">
<rect key="frame" x="8" y="31" width="99.5" height="19"/>
<rect key="frame" x="8" y="28" width="104" height="22"/>
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="16"/>
<color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="joW-cG-ai8" userLabel="Separator View">
<rect key="frame" x="115.5" y="10" width="1" height="30"/>
<rect key="frame" x="120" y="10" width="1" height="30"/>
<color key="backgroundColor" red="0.77900850772857666" green="0.78811043500900269" blue="0.79274082183837891" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="Jj2-tX-SU9"/>
@@ -1092,21 +1093,21 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5is-0I-Kv3" userLabel="Hours View">
<rect key="frame" x="116.5" y="0.0" width="116.5" height="50"/>
<rect key="frame" x="121" y="0.0" width="121" height="50"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="24" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gaG-Iv-Xyq">
<rect key="frame" x="8" y="0.0" width="100.5" height="24.5"/>
<rect key="frame" x="8" y="0.0" width="105" height="29"/>
<fontDescription key="fontDescription" name="OpenSans-Semibold" family="Open Sans" pointSize="21"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hours Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c2J-Uj-KEg" userLabel="Hours Description Label">
<rect key="frame" x="8" y="31" width="100.5" height="19"/>
<rect key="frame" x="8" y="28" width="105" height="22"/>
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="16"/>
<color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JBv-xm-KUq" userLabel="Separator View">
<rect key="frame" x="115.5" y="10" width="1" height="30"/>
<rect key="frame" x="120" y="10" width="1" height="30"/>
<color key="backgroundColor" red="0.81960784313725488" green="0.82745098039215681" blue="0.83137254901960778" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="Gck-dw-et7"/>
@@ -1126,15 +1127,15 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tvc-eS-Us6" userLabel="Minutes View">
<rect key="frame" x="233" y="0.0" width="116.5" height="50"/>
<rect key="frame" x="242" y="0.0" width="121" height="50"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="59" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Txm-uf-MP4">
<rect key="frame" x="8" y="0.0" width="100.5" height="24.5"/>
<rect key="frame" x="8" y="0.0" width="105" height="29"/>
<fontDescription key="fontDescription" name="OpenSans-Semibold" family="Open Sans" pointSize="21"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Minutes Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EES-a9-qxv" userLabel="Minutes Description Label">
<rect key="frame" x="8" y="31" width="100.5" height="19"/>
<rect key="frame" x="8" y="28" width="105" height="22"/>
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="16"/>
<color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
@@ -1370,7 +1371,7 @@
<scene sceneID="s4S-5p-4o1">
<objects>
<navigationController id="I54-NN-JAf" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="Qb2-vc-6Pl">
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="Qb2-vc-6Pl">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
@@ -2132,7 +2133,7 @@
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="4Fb-v3-mkB" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="opw-zV-Qak">
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="opw-zV-Qak">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
@@ -2150,7 +2151,7 @@
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="dfN-Ch-vpm" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="IvG-lp-FEV">
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="IvG-lp-FEV">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
@@ -2218,7 +2219,7 @@
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="Njg-ZD-Ycd" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="bNh-Bg-ROM">
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" id="bNh-Bg-ROM">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
@@ -2243,8 +2244,8 @@
<image name="settings" width="22" height="22"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="QMa-LQ-D8c"/>
<segue reference="Xxn-jp-xEB"/>
<segue reference="QMa-LQ-D8c"/>
<segue reference="fgS-yf-c3u"/>
</inferredMetricsTieBreakers>
<color key="tintColor" red="0.0" green="0.61568627450980395" blue="0.8784313725490196" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -252,6 +252,7 @@ class SignUpRequestManager: NSObject {
failure: @escaping (_ error: Error, _ message: String?) -> Void)
{
let urlString = "\(basePathString)/logout/"
manager.requestSerializer.clearAuthorizationHeader()
manager.post(urlString, parameters: nil, success: { (requestOperation, responseObject) in
self.postLogoutSuccess(success: success)
}) { (requestOperation, error) in
@@ -9,7 +9,7 @@
import UIKit
import CoreData
class TrainingTableViewController: UIViewController {
class TrainingTableViewController: CheckInTableViewController {
fileprivate struct Segue {
static let About = "About"
@@ -20,14 +20,10 @@ class TrainingTableViewController: UIViewController {
var signUpController: SignUpController!
var userName: String!
@IBOutlet var headerView: UIView!
@IBOutlet weak var headerTitleLabel: UILabel!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var footerTextView: UITextView!
@IBOutlet weak var addButton: UIButton!
override func viewDidLoad() {
delegate = self
super.viewDidLoad()
setup()
}
@@ -36,35 +32,11 @@ class TrainingTableViewController: UIViewController {
fileprivate func setup() {
setupAddButton()
setupTableView()
setupTableViewDataSource()
setupTableViewHeader()
}
fileprivate func setupAddButton() {
makeViewRoundWithShadow(addButton)
}
fileprivate func setupTableView() {
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 140
}
fileprivate func setupTableViewDataSource() {
do {
try fetchedResultsController.performFetch()
} catch {
logError(name: "\(#function)", error: error)
}
}
fileprivate func setupTableViewHeader() {
if fetchedResultsController.sections?[0].numberOfObjects ?? 0 == 0 {
tableView.tableHeaderView = nil
} else {
tableView.tableHeaderView = headerView
}
}
// MARK: - Actions
@@ -97,9 +69,10 @@ class TrainingTableViewController: UIViewController {
// MARK: - Segues
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)
if (segue.identifier == Segue.CreateTraining) {
let createTrainingNC = segue.destination as! UINavigationController
let createTrainingVC = createTrainingNC.viewControllers[0] as! CreateTrainingViewController
guard let createTrainingNC = segue.destination as? UINavigationController else { return }
guard let createTrainingVC = createTrainingNC.viewControllers[0] as? CreateTrainingViewController else { return }
createTrainingVC.trainingCoreDataManager = trainingCoreDataManager;
createTrainingVC.trainingController = trainingController
}
@@ -117,80 +90,31 @@ class TrainingTableViewController: UIViewController {
return trainingCoreDataManager
}()
fileprivate lazy var fetchedResultsController: NSFetchedResultsController<CheckIn> = {
let fetchedResultsController = self.trainingCoreDataManager.checkInFetchedResultsController()
fetchedResultsController.delegate = self
return fetchedResultsController
}()
}
// MARK: - UITableViewDataSource
// MARK: - CheckInTableViewControllerDelegate
extension TrainingTableViewController: UITableViewDataSource {
extension TrainingTableViewController: CheckInTableViewControllerDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fetchedResultsController.sections?[section].numberOfObjects ?? 0
var coreDataManager: CoreDataManager {
get {
return trainingCoreDataManager
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") ?? UITableViewCell()
self.configureCell(cell: cell, atIndexPath: indexPath)
return cell
}
func configureCell(cell: UITableViewCell, atIndexPath indexPath: IndexPath) {
func checkInTableViewController(_ controller: CheckInTableViewController, configureCell cell: UITableViewCell, forCheckIn checkIn: CheckIn) {
guard let trainingTableViewCell = cell as? TrainingTableViewCell else { return }
let checkIn = fetchedResultsController.object(at: indexPath)
trainingTableViewCell.eventLabel.text = checkIn.event.name
trainingTableViewCell.leaderboardLabel.text = checkIn.leaderboard.name
trainingTableViewCell.competitorLabel.text = checkIn.name
}
}
// MARK: - UITableViewDelegate
extension TrainingTableViewController: UITableViewDelegate {
}
// MARK: - NSFetchedResultsControllerDelegate
extension TrainingTableViewController: NSFetchedResultsControllerDelegate {
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
tableView.beginUpdates()
func checkInTableViewController(_ controller: CheckInTableViewController, prepareForSegue segue: UIStoryboardSegue, andCompetitorCheckIn checkIn: CompetitorCheckIn) {
}
func controller(
_ controller: NSFetchedResultsController<NSFetchRequestResult>,
didChange object: Any,
at indexPath: IndexPath?,
for type: NSFetchedResultsChangeType,
newIndexPath: IndexPath?)
{
switch type {
case .insert:
tableView.insertRows(at: [newIndexPath!], with: UITableViewRowAnimation.automatic)
case .update:
let cell = tableView.cellForRow(at: indexPath!)
if cell != nil {
configureCell(cell: cell!, atIndexPath: indexPath!)
tableView.reloadRows(at: [indexPath!], with: UITableViewRowAnimation.automatic)
}
case .move:
tableView.deleteRows(at: [indexPath!], with: UITableViewRowAnimation.automatic)
tableView.insertRows(at: [newIndexPath!], with: .automatic)
case .delete:
tableView.deleteRows(at: [indexPath!], with: UITableViewRowAnimation.automatic)
}
}
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
tableView.endUpdates()
setupTableViewHeader()
func checkInTableViewController(_ controller: CheckInTableViewController, prepareForSegue segue: UIStoryboardSegue, andMarkCheckIn checkIn: MarkCheckIn) {
}
}