Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
xcuserdata

5 changes: 5 additions & 0 deletions ToDoList.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
TargetAttributes = {
954D24811B7A2DDA00DD9E4E = {
CreatedOnToolsVersion = 6.4;
DevelopmentTeam = TXV64D6H4A;
};
954D24961B7A2DDA00DD9E4E = {
CreatedOnToolsVersion = 6.4;
Expand Down Expand Up @@ -367,21 +368,25 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = TXV64D6H4A;
INFOPLIST_FILE = ToDoList/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.purecreek.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
954D24A31B7A2DDB00DD9E4E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = TXV64D6H4A;
INFOPLIST_FILE = ToDoList/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.purecreek.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
Empty file modified ToDoList.xcodeproj/project.xcworkspace/contents.xcworkspacedata
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Empty file.
Empty file.
24 changes: 12 additions & 12 deletions ToDoList/AddToDoItemViewController.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class AddToDoItemViewController: UIViewController {
@IBOutlet weak var nameTextField: UITextField!

var stateController: StateController?
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let tappedButton = sender as? UIBarButtonItem where tappedButton != cancelButton else {
return;
}
guard let text = nameTextField.text else {
return
}
let todoItem = ToDoItem(name: text, completed: false, creationDate: NSDate())
stateController?.addItem(todoItem)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let tappedButton = sender as? UIBarButtonItem, tappedButton != cancelButton else {
return;
}
guard let text = nameTextField.text else {
return
}
let todoItem = ToDoItem(name: text, completed: false, creationDate: NSDate())
stateController?.addItem(item: todoItem)
}
}
20 changes: 11 additions & 9 deletions ToDoList/AppDelegate.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let stateController = StateController()

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
if let navigationController = window?.rootViewController as? UINavigationController,
let toDoListTableViewController = navigationController.viewControllers.first as? ToDoListTableViewController {
toDoListTableViewController.stateController = stateController
}
return true
}
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool
{
if let navigationController = window?.rootViewController as? UINavigationController,
let toDoListTableViewController = navigationController.viewControllers.first as? ToDoListTableViewController {
toDoListTableViewController.stateController = stateController
}
return true
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
stateController.save()
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
stateController.save()
}
}
Expand Down
Empty file modified ToDoList/Base.lproj/LaunchScreen.xib
100644 → 100755
Empty file.
33 changes: 20 additions & 13 deletions ToDoList/Base.lproj/Main.storyboard
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="GwT-36-HoN">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="GwT-36-HoN">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="ehg-Ox-owk">
<objects>
<navigationController id="GwT-36-HoN" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="UUg-LA-X9P">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -26,16 +30,19 @@
<objects>
<tableViewController id="D54-iA-aJQ" customClass="ToDoListTableViewController" customModule="ToDoList" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Vzs-6T-8dB">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="ToDoItemCell" textLabel="8dI-yn-INn" style="IBUITableViewCellStyleDefault" id="zAc-qw-Uu3" customClass="ToDoItemCell" customModule="ToDoList" customModuleProvider="target">
<rect key="frame" x="0.0" y="22" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="zAc-qw-Uu3" id="639-JW-Vak">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="8dI-yn-INn">
<rect key="frame" x="16" y="0.0" width="343" height="43.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
Expand Down Expand Up @@ -71,16 +78,16 @@
<viewControllerLayoutGuide type="bottom" id="iBz-8H-3ry"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="DbP-1W-30d">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="New to-do item" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Ptn-l6-Jhc">
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="New to-do item" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Ptn-l6-Jhc">
<rect key="frame" x="16" y="72" width="568" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Ptn-l6-Jhc" firstAttribute="top" secondItem="cRc-Ry-ng6" secondAttribute="bottom" constant="8" id="DD7-I3-Twd"/>
<constraint firstItem="Ptn-l6-Jhc" firstAttribute="trailing" secondItem="DbP-1W-30d" secondAttribute="trailingMargin" id="VeJ-9p-CTJ"/>
Expand All @@ -90,12 +97,12 @@
<navigationItem key="navigationItem" title="Add To-Do Item" id="IJY-dD-pe1">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="8fr-LN-Fea">
<connections>
<segue destination="BND-B3-xGa" kind="unwind" unwindAction="unwindToList:" id="kH7-Pt-wR9"/>
<segue destination="BND-B3-xGa" kind="unwind" unwindAction="unwindToListWithSegue:" id="O7o-FD-skB"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" systemItem="save" id="wwo-dz-Wu8">
<connections>
<segue destination="BND-B3-xGa" kind="unwind" unwindAction="unwindToList:" id="jH7-G6-jcI"/>
<segue destination="BND-B3-xGa" kind="unwind" unwindAction="unwindToListWithSegue:" id="TGP-Ng-J4U"/>
</connections>
</barButtonItem>
</navigationItem>
Expand All @@ -116,7 +123,7 @@
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="qjo-ed-Xkd" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="xB7-KY-yGN">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand Down
Empty file modified ToDoList/Images.xcassets/AppIcon.appiconset/Contents.json
100644 → 100755
Empty file.
Empty file modified ToDoList/Info.plist
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions ToDoList/StateController.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import Foundation

class StateController {
static let itemsFilePath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first! + "/items.txt"
static let itemsFilePath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! + "/items.txt"

private(set) var items: [ToDoItem] = {
if let items = NSKeyedUnarchiver.unarchiveObjectWithFile(itemsFilePath) as? [ToDoItem] {
if let items = NSKeyedUnarchiver.unarchiveObject(withFile: itemsFilePath) as? [ToDoItem] {
return items
} else {
return [ToDoItem]()
Expand All @@ -26,4 +26,4 @@ class StateController {
func save() {
NSKeyedArchiver.archiveRootObject(self.items, toFile: StateController.itemsFilePath)
}
}
}
8 changes: 4 additions & 4 deletions ToDoList/TableViewDataSource.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ class TableViewDataSource: NSObject {

extension TableViewDataSource: UITableViewDataSource {

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return stateController.items.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let toDoItem = stateController.items[indexPath.row]
let cell = tableView.dequeueReusableCellWithIdentifier(ToDoItemCell.identifier, forIndexPath: indexPath) as! ToDoItemCell
let cell = tableView.dequeueReusableCell(withIdentifier: ToDoItemCell.identifier, for: indexPath) as! ToDoItemCell
cell.name = toDoItem.name
cell.completed = toDoItem.completed
return cell
}

}
}
8 changes: 4 additions & 4 deletions ToDoList/TableViewDelegate.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class TableViewDelegate: NSObject {

extension TableViewDelegate: UITableViewDelegate {

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: false)
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: false)
let tappedItem = stateController.items[indexPath.row]
tappedItem.completed = !tappedItem.completed
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.None)
tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
}

}
}
17 changes: 9 additions & 8 deletions ToDoList/ToDoItem.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import Foundation

class ToDoItem: NSObject, NSCoding {
let name: String

let name: String
let creationDate: NSDate
var completed: Bool

Expand All @@ -20,15 +21,15 @@ class ToDoItem: NSObject, NSCoding {
}

required init?(coder aDecoder: NSCoder) {
name = aDecoder.decodeObjectForKey(Keys.Name.rawValue) as! String
completed = aDecoder.decodeObjectForKey(Keys.Completed.rawValue) as! Bool
creationDate = aDecoder.decodeObjectForKey(Keys.CreationDate.rawValue) as! NSDate
name = aDecoder.decodeObject(forKey: Keys.Name.rawValue) as! String
completed = aDecoder.decodeObject(forKey: Keys.Completed.rawValue) as! Bool
creationDate = aDecoder.decodeObject(forKey: Keys.CreationDate.rawValue) as! NSDate
}

func encodeWithCoder(aCoder: NSCoder) {
aCoder.encodeObject(name, forKey: Keys.Name.rawValue)
aCoder.encodeObject(completed, forKey: Keys.Completed.rawValue)
aCoder.encodeObject(creationDate, forKey: Keys.CreationDate.rawValue)
func encode(with aCoder: NSCoder) {
aCoder.encode(name, forKey: Keys.Name.rawValue)
aCoder.encode(completed, forKey: Keys.Completed.rawValue)
aCoder.encode(creationDate, forKey: Keys.CreationDate.rawValue)
}

enum Keys: String {
Expand Down
4 changes: 2 additions & 2 deletions ToDoList/ToDoItemCell.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class ToDoItemCell: UITableViewCell {
var completed: Bool = false {
didSet {
if (completed) {
accessoryType = UITableViewCellAccessoryType.Checkmark
accessoryType = UITableViewCell.AccessoryType.checkmark
} else {
accessoryType = UITableViewCellAccessoryType.None;
accessoryType = UITableViewCell.AccessoryType.none;
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions ToDoList/ToDoListTableViewController.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ class ToDoListTableViewController: UITableViewController {
}
}

override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
tableView.reloadData()
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let navigationController = segue.destinationViewController as? UINavigationController,
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let navigationController = segue.destination as? UINavigationController,
let addToDoItemViewController = navigationController.viewControllers.first as? AddToDoItemViewController {
addToDoItemViewController.stateController = stateController
}
}

@IBAction func unwindToList(segue: UIStoryboardSegue) {
}
@IBAction func unwindToList(segue: UIStoryboardSegue) {
print("unwindToList")
}

}

Empty file modified ToDoListTests/Info.plist
100644 → 100755
Empty file.
Empty file modified ToDoListTests/ToDoListTests.swift
100644 → 100755
Empty file.