diff --git a/Checklists.xcodeproj/project.pbxproj b/Checklists.xcodeproj/project.pbxproj index 65a9555..4dc243b 100644 --- a/Checklists.xcodeproj/project.pbxproj +++ b/Checklists.xcodeproj/project.pbxproj @@ -8,20 +8,22 @@ /* Begin PBXBuildFile section */ A81172C51CD0660E00BA3196 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81172C41CD0660E00BA3196 /* AppDelegate.swift */; }; - A81172C71CD0660E00BA3196 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81172C61CD0660E00BA3196 /* ViewController.swift */; }; + A81172C71CD0660E00BA3196 /* ChecklistViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81172C61CD0660E00BA3196 /* ChecklistViewController.swift */; }; A81172CA1CD0660E00BA3196 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A81172C81CD0660E00BA3196 /* Main.storyboard */; }; A81172CC1CD0660F00BA3196 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A81172CB1CD0660F00BA3196 /* Assets.xcassets */; }; A81172CF1CD0660F00BA3196 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A81172CD1CD0660F00BA3196 /* LaunchScreen.storyboard */; }; + A81172D91CD0859800BA3196 /* ChecklistItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81172D81CD0859800BA3196 /* ChecklistItem.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ A81172C11CD0660E00BA3196 /* Checklists.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Checklists.app; sourceTree = BUILT_PRODUCTS_DIR; }; A81172C41CD0660E00BA3196 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - A81172C61CD0660E00BA3196 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + A81172C61CD0660E00BA3196 /* ChecklistViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChecklistViewController.swift; sourceTree = ""; }; A81172C91CD0660E00BA3196 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; A81172CB1CD0660F00BA3196 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; A81172CE1CD0660F00BA3196 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; A81172D01CD0660F00BA3196 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A81172D81CD0859800BA3196 /* ChecklistItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChecklistItem.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -55,11 +57,12 @@ isa = PBXGroup; children = ( A81172C41CD0660E00BA3196 /* AppDelegate.swift */, - A81172C61CD0660E00BA3196 /* ViewController.swift */, + A81172C61CD0660E00BA3196 /* ChecklistViewController.swift */, A81172C81CD0660E00BA3196 /* Main.storyboard */, A81172CB1CD0660F00BA3196 /* Assets.xcassets */, A81172CD1CD0660F00BA3196 /* LaunchScreen.storyboard */, A81172D01CD0660F00BA3196 /* Info.plist */, + A81172D81CD0859800BA3196 /* ChecklistItem.swift */, ); path = Checklists; sourceTree = ""; @@ -136,7 +139,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - A81172C71CD0660E00BA3196 /* ViewController.swift in Sources */, + A81172C71CD0660E00BA3196 /* ChecklistViewController.swift in Sources */, + A81172D91CD0859800BA3196 /* ChecklistItem.swift in Sources */, A81172C51CD0660E00BA3196 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Checklists.xcodeproj/xcuserdata/mriddle.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Checklists.xcodeproj/xcuserdata/mriddle.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..4512409 --- /dev/null +++ b/Checklists.xcodeproj/xcuserdata/mriddle.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,39 @@ + + + + + + + + + + + + + diff --git a/Checklists.xcodeproj/xcuserdata/mriddle.xcuserdatad/xcschemes/Checklists.xcscheme b/Checklists.xcodeproj/xcuserdata/mriddle.xcuserdatad/xcschemes/Checklists.xcscheme index 9a1df9b..d736a4b 100644 --- a/Checklists.xcodeproj/xcuserdata/mriddle.xcuserdatad/xcschemes/Checklists.xcscheme +++ b/Checklists.xcodeproj/xcuserdata/mriddle.xcuserdatad/xcschemes/Checklists.xcscheme @@ -5,6 +5,22 @@ + + + + + + + + + + @@ -26,6 +51,16 @@ debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> + + + + @@ -35,6 +70,16 @@ savedToolIdentifier = "" useCustomWorkingDirectory = "NO" debugDocumentVersioning = "YES"> + + + + diff --git a/Checklists/Base.lproj/Main.storyboard b/Checklists/Base.lproj/Main.storyboard index 3a2a49b..85c755e 100644 --- a/Checklists/Base.lproj/Main.storyboard +++ b/Checklists/Base.lproj/Main.storyboard @@ -1,25 +1,45 @@ - + - + + - - + + - - - - - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/Checklists/ChecklistItem.swift b/Checklists/ChecklistItem.swift new file mode 100644 index 0000000..2281def --- /dev/null +++ b/Checklists/ChecklistItem.swift @@ -0,0 +1,21 @@ +// +// ChecklistItem.swift +// Checklists +// +// Created by Matthew Riddle on 27/04/2016. +// Copyright © 2016 Matthew Riddle. All rights reserved. +// + +import Foundation + +class ChecklistItem { + var text: String + var checked: Bool + + init(text: String, checked: Bool) { + self.text = text + self.checked = checked + } + + +} \ No newline at end of file diff --git a/Checklists/ChecklistViewController.swift b/Checklists/ChecklistViewController.swift new file mode 100644 index 0000000..7bba5b7 --- /dev/null +++ b/Checklists/ChecklistViewController.swift @@ -0,0 +1,75 @@ +// +// ViewController.swift +// Checklists +// +// Created by Matthew Riddle on 27/04/2016. +// Copyright © 2016 Matthew Riddle. All rights reserved. +// + +import UIKit + +class ChecklistViewController: UITableViewController { + var items: Array = [ + ChecklistItem(text: "Walk the dog", checked: false), + ChecklistItem(text: "Brush teeth", checked: false), + ChecklistItem(text: "Learn iOS development", checked: false), + ChecklistItem(text: "Soccer practice", checked: false), + ChecklistItem(text: "Eat ice cream", checked: false) + ] + + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 5 + } + + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCellWithIdentifier("ChecklistItem", forIndexPath: indexPath) + + let label = cell.viewWithTag(1000) as! UILabel + + if indexPath.row < items.count { + label.text = items[indexPath.row].text + } + configureCheckmarkForCell(cell, atIndexPath: indexPath) + return cell + } + + override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + + if let cell = tableView.cellForRowAtIndexPath(indexPath) { + if indexPath.row < items.count { + let item = items[indexPath.row] + item.checked = !item.checked + } + + configureCheckmarkForCell(cell, atIndexPath: indexPath) + } + + tableView.deselectRowAtIndexPath(indexPath, animated: true) + } + + func configureCheckmarkForCell(cell: UITableViewCell, atIndexPath: NSIndexPath) { + if atIndexPath.row < items.count { + let item = items[atIndexPath.row] + + if item.checked { + cell.accessoryType = .Checkmark + } else { + cell.accessoryType = .None + } + } + } + + +} + diff --git a/Checklists/Info.plist b/Checklists/Info.plist index 6905cc6..6c48029 100644 --- a/Checklists/Info.plist +++ b/Checklists/Info.plist @@ -33,8 +33,6 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight diff --git a/Checklists/ViewController.swift b/Checklists/ViewController.swift deleted file mode 100644 index 91d19e1..0000000 --- a/Checklists/ViewController.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// ViewController.swift -// Checklists -// -// Created by Matthew Riddle on 27/04/2016. -// Copyright © 2016 Matthew Riddle. All rights reserved. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - -} -