Last active
August 29, 2015 14:23
-
-
Save codebeaulieu/5c504709b9ae01cddcf8 to your computer and use it in GitHub Desktop.
french controller
This file contains 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
// | |
// FrenchPressTableViewController.swift | |
// CoffeePro | |
// | |
// Created by Dan Beaulieu on 6/10/15. | |
// Copyright © 2015 Dan Beaulieu. All rights reserved. | |
// | |
import UIKit | |
class FrenchPressTableViewController: UITableViewController, SwitchCellDelegate { | |
var frenchSettings = [Setting]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
frenchSettings = [] | |
let dict = AppDelegate().french | |
for (k, v) in dict { | |
switch "\(v.dynamicType)" { | |
case "__NSCFBoolean": | |
let switchSet = Setting(label: k, state: v as Bool) | |
frenchSettings.append(switchSet) | |
case "__NSCFNumber": | |
let timeSet = Setting(label: k, time: v as Int) | |
frenchSettings.append(timeSet) | |
default: break | |
} | |
} | |
} | |
func didChangeSwitchState(sender sender: SwitchCell, isOn: Bool) { | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
// MARK: - Table view data source | |
override func numberOfSectionsInTableView(tableView: UITableView) -> Int { | |
// #warning Incomplete implementation, return the number of sections | |
return 1 | |
} | |
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
// #warning Incomplete implementation, return the number of rows | |
return frenchSettings.count | |
} | |
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { | |
let frenchSets = frenchSettings[indexPath.row] | |
print(frenchSets.settingsLabel) | |
if (frenchSets.switchState != nil) { | |
let cell = tableView.dequeueReusableCellWithIdentifier("SwitchCell", forIndexPath: indexPath) as! SwitchCell | |
cell.switchLabel.text = frenchSets.settingsLabel | |
cell.switchState.on = frenchSets.switchState! | |
//cell.cellDelegate = self | |
cell.backgroundColor = UIColor.clearColor() | |
return cell | |
} else { | |
let cell2 = tableView.dequeueReusableCellWithIdentifier("IntCell", forIndexPath: indexPath) as! TimingCell | |
cell2.timingLabel.text = frenchSets.settingsLabel | |
cell2.savedTimeLabel.setTitle(String(frenchSets.timing!), forState: UIControlState.Normal) | |
cell2.savedTimeLabel.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Right | |
return cell2 | |
} | |
// Configure the cell... | |
} | |
/* | |
// Override to support conditional editing of the table view. | |
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { | |
// Return false if you do not want the specified item to be editable. | |
return true | |
} | |
*/ | |
/* | |
// Override to support editing the table view. | |
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { | |
if editingStyle == .Delete { | |
// Delete the row from the data source | |
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) | |
} else if editingStyle == .Insert { | |
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view | |
} | |
} | |
*/ | |
/* | |
// Override to support rearranging the table view. | |
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { | |
} | |
*/ | |
/* | |
// Override to support conditional rearranging of the table view. | |
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { | |
// Return NO if you do not want the item to be re-orderable. | |
return true | |
} | |
*/ | |
/* | |
// MARK: - Navigation | |
// In a storyboard-based application, you will often want to do a little preparation before navigation | |
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | |
// Get the new view controller using segue.destinationViewController. | |
// Pass the selected object to the new view controller. | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment