diff --git a/session-2/SwiftlyDublinToDo/AppDelegate.swift b/session-2/SwiftlyDublinToDo/AppDelegate.swift
new file mode 100644
index 0000000..d4246fc
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/AppDelegate.swift
@@ -0,0 +1,111 @@
+//
+// AppDelegate.swift
+// SwiftlyDublinToDo
+//
+// Created by Ciaran O hUallachain on 29/10/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import UIKit
+import CoreData
+
+@UIApplicationMain
+class AppDelegate: UIResponder, UIApplicationDelegate {
+
+ var window: UIWindow?
+
+
+ func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
+ // Override point for customization after application launch.
+ return true
+ }
+
+ func applicationWillResignActive(application: UIApplication) {
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+ }
+
+ func applicationDidEnterBackground(application: UIApplication) {
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+ }
+
+ func applicationWillEnterForeground(application: UIApplication) {
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+ }
+
+ func applicationDidBecomeActive(application: UIApplication) {
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+ }
+
+ func applicationWillTerminate(application: UIApplication) {
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+ // Saves changes in the application's managed object context before the application terminates.
+ self.saveContext()
+ }
+
+ // MARK: - Core Data stack
+
+ lazy var applicationDocumentsDirectory: NSURL = {
+ // The directory the application uses to store the Core Data store file. This code uses a directory named "com.ciaranoh.SwiftlyDublinToDo" in the application's documents Application Support directory.
+ let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
+ return urls[urls.count-1] as NSURL
+ }()
+
+ lazy var managedObjectModel: NSManagedObjectModel = {
+ // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
+ let modelURL = NSBundle.mainBundle().URLForResource("SwiftlyDublinToDo", withExtension: "momd")!
+ return NSManagedObjectModel(contentsOfURL: modelURL)!
+ }()
+
+ lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
+ // The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
+ // Create the coordinator and store
+ var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
+ let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("SwiftlyDublinToDo.sqlite")
+ var error: NSError? = nil
+ var failureReason = "There was an error creating or loading the application's saved data."
+ if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil {
+ coordinator = nil
+ // Report any error we got.
+ let dict = NSMutableDictionary()
+ dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
+ dict[NSLocalizedFailureReasonErrorKey] = failureReason
+ dict[NSUnderlyingErrorKey] = error
+ error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
+ // Replace this with code to handle the error appropriately.
+ // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
+ NSLog("Unresolved error \(error), \(error!.userInfo)")
+ abort()
+ }
+
+ return coordinator
+ }()
+
+ lazy var managedObjectContext: NSManagedObjectContext? = {
+ // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail.
+ let coordinator = self.persistentStoreCoordinator
+ if coordinator == nil {
+ return nil
+ }
+ var managedObjectContext = NSManagedObjectContext()
+ managedObjectContext.persistentStoreCoordinator = coordinator
+ return managedObjectContext
+ }()
+
+ // MARK: - Core Data Saving support
+
+ func saveContext () {
+ if let moc = self.managedObjectContext {
+ var error: NSError? = nil
+ if moc.hasChanges && !moc.save(&error) {
+ // Replace this implementation with code to handle the error appropriately.
+ // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
+ NSLog("Unresolved error \(error), \(error!.userInfo)")
+ abort()
+ }
+ }
+ }
+
+}
+
diff --git a/session-2/SwiftlyDublinToDo/Base.lproj/LaunchScreen.xib b/session-2/SwiftlyDublinToDo/Base.lproj/LaunchScreen.xib
new file mode 100644
index 0000000..41e87b0
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/Base.lproj/LaunchScreen.xib
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/session-2/SwiftlyDublinToDo/Base.lproj/Main.storyboard b/session-2/SwiftlyDublinToDo/Base.lproj/Main.storyboard
new file mode 100644
index 0000000..5a01707
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/Base.lproj/Main.storyboard
@@ -0,0 +1,131 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/session-2/SwiftlyDublinToDo/Images.xcassets/AppIcon.appiconset/Contents.json b/session-2/SwiftlyDublinToDo/Images.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 0000000..118c98f
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/Images.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "images" : [
+ {
+ "idiom" : "iphone",
+ "size" : "29x29",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "29x29",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "40x40",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "40x40",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "60x60",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "60x60",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/session-2/SwiftlyDublinToDo/Info.plist b/session-2/SwiftlyDublinToDo/Info.plist
new file mode 100644
index 0000000..15aee61
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/Info.plist
@@ -0,0 +1,40 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ com.ciaranoh.$(PRODUCT_NAME:rfc1034identifier)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1
+ LSRequiresIPhoneOS
+
+ UILaunchStoryboardName
+ LaunchScreen
+ UIMainStoryboardFile
+ Main
+ UIRequiredDeviceCapabilities
+
+ armv7
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+
+
diff --git a/session-2/SwiftlyDublinToDo/SwiftlyDublinToDo.xcdatamodeld/.xccurrentversion b/session-2/SwiftlyDublinToDo/SwiftlyDublinToDo.xcdatamodeld/.xccurrentversion
new file mode 100644
index 0000000..24dd4fc
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/SwiftlyDublinToDo.xcdatamodeld/.xccurrentversion
@@ -0,0 +1,8 @@
+
+
+
+
+ _XCCurrentVersionName
+ SwiftlyDublinToDo.xcdatamodel
+
+
diff --git a/session-2/SwiftlyDublinToDo/SwiftlyDublinToDo.xcdatamodeld/SwiftlyDublinToDo.xcdatamodel/contents b/session-2/SwiftlyDublinToDo/SwiftlyDublinToDo.xcdatamodeld/SwiftlyDublinToDo.xcdatamodel/contents
new file mode 100644
index 0000000..8f8367c
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/SwiftlyDublinToDo.xcdatamodeld/SwiftlyDublinToDo.xcdatamodel/contents
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/session-2/SwiftlyDublinToDo/ToDoEntity.swift b/session-2/SwiftlyDublinToDo/ToDoEntity.swift
new file mode 100644
index 0000000..a499047
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/ToDoEntity.swift
@@ -0,0 +1,18 @@
+//
+// ToDoEntity.swift
+// SwiftlyDublinToDo
+//
+// Created by Ciaran O hUallachain on 29/10/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import Foundation
+import CoreData
+
+class ToDoEntity: NSManagedObject {
+
+ @NSManaged var toDoDescription: String
+ @NSManaged var toDoTitle: String
+ @NSManaged var complete: NSNumber
+
+}
diff --git a/session-2/SwiftlyDublinToDo/ToDoViewController.swift b/session-2/SwiftlyDublinToDo/ToDoViewController.swift
new file mode 100644
index 0000000..aad0b10
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/ToDoViewController.swift
@@ -0,0 +1,102 @@
+//
+// ToDoViewController.swift
+// SwiftlyDublinToDo
+//
+// Created by Ciaran O hUallachain on 29/10/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import UIKit
+import CoreData
+
+class ToDoViewController: UIViewController {
+ var toDoEntity: ToDoEntity? = nil
+ var toDoDelegate: ViewController? = nil
+ @IBOutlet var toDoTitleTextField : UITextField!
+ @IBOutlet var toDoDescriptionTextView : UITextView!
+ @IBOutlet var toDoStatusSwitch: UISwitch!
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ // Do any additional setup after loading the view.
+ }
+
+ override func viewWillAppear(animated: Bool) {
+ if let entity: ToDoEntity = self.toDoEntity {
+ self.toDoTitleTextField.text = entity.toDoTitle
+ self.toDoDescriptionTextView.text = entity.toDoDescription
+ self.toDoStatusSwitch.on = entity.complete.boolValue
+ } else {
+ self.toDoStatusSwitch.on = false
+ }
+ super.viewWillAppear(animated)
+ }
+
+ override func didReceiveMemoryWarning() {
+ super.didReceiveMemoryWarning()
+ // Dispose of any resources that can be recreated.
+ }
+
+ @IBAction func save() {
+ println("saving")
+ let titleText: NSString = self.toDoTitleTextField.text
+ if (titleText.length == 0) {
+ return
+ }
+
+ if (!updateItem()) {
+ saveNewItem()
+ }
+ if let delegate = self.toDoDelegate {
+ toDoDelegate?.reloadInputViews()
+ }
+ self.navigationController?.popViewControllerAnimated(true)
+ }
+
+ func saveNewItem() -> Bool {
+ var success = true
+ let appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
+ let context: NSManagedObjectContext = appDelegate.managedObjectContext!
+ let entityName: NSString = "ToDoEntity"
+ var toDoItem: ToDoEntity! = NSEntityDescription.insertNewObjectForEntityForName(entityName, inManagedObjectContext: context) as ToDoEntity
+ toDoItem.toDoTitle = self.toDoTitleTextField.text
+ toDoItem.toDoDescription = self.toDoDescriptionTextView.text
+ toDoItem.complete = self.toDoStatusSwitch.on
+ var error: NSError? = nil
+ if (!context.save(&error)) {
+ println(error)
+ success = false
+ }
+ return success
+ }
+
+ func updateItem() -> Bool {
+ var success = false
+ let appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
+ let context: NSManagedObjectContext = appDelegate.managedObjectContext!
+ if let toDoItem = self.toDoEntity {
+ toDoItem.toDoTitle = self.toDoTitleTextField.text
+ toDoItem.toDoDescription = self.toDoDescriptionTextView.text
+ toDoItem.complete = self.toDoStatusSwitch.on
+ var error: NSError? = nil
+ if (!context.save(&error)) {
+ println(error)
+ } else {
+ success = true
+ }
+ }
+ return success
+ }
+
+ /*
+ // 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.
+ }
+ */
+
+}
diff --git a/session-2/SwiftlyDublinToDo/ViewController.swift b/session-2/SwiftlyDublinToDo/ViewController.swift
new file mode 100644
index 0000000..64c0291
--- /dev/null
+++ b/session-2/SwiftlyDublinToDo/ViewController.swift
@@ -0,0 +1,86 @@
+//
+// ViewController.swift
+// SwiftlyDublinToDo
+//
+// Created by Ciaran O hUallachain on 29/10/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import UIKit
+import CoreData
+
+class ViewController: UITableViewController {
+
+ var toDoItems = [ToDoEntity]()
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+ // Do any additional setup after loading the view, typically from a nib.
+ loadToDoItems()
+ }
+
+ override func didReceiveMemoryWarning() {
+ super.didReceiveMemoryWarning()
+ // Dispose of any resources that can be recreated.
+ }
+
+ override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+ return toDoItems.count
+ }
+
+ override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
+ let cell = tableView.dequeueReusableCellWithIdentifier("ToDoCell") as UITableViewCell
+ let toDoItem = toDoItems[indexPath.row]
+ cell.textLabel.text = toDoItem.toDoTitle
+ cell.accessoryType = toDoItem.complete.boolValue ? UITableViewCellAccessoryType.Checkmark : UITableViewCellAccessoryType.None
+ return cell
+ }
+
+ override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
+ println(indexPath.row.description)
+ tableView.deselectRowAtIndexPath(indexPath, animated: true)
+ }
+
+ func loadToDoItems() {
+ let appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
+ let context: NSManagedObjectContext = appDelegate.managedObjectContext!
+ let entityName: NSString = "ToDoEntity"
+
+ var error: NSError? = nil
+ var fetchRequest: NSFetchRequest = NSFetchRequest(entityName: entityName)
+ fetchRequest.resultType = NSFetchRequestResultType.ManagedObjectResultType
+ let results: NSArray = context.executeFetchRequest(fetchRequest, error: &error)!
+
+ toDoItems = [ToDoEntity]()
+ for data in results {
+ var toDoEntity = data as ToDoEntity
+ toDoItems.append(toDoEntity)
+ }
+ }
+
+ // 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.
+
+ let toDoController: ToDoViewController = segue.destinationViewController as ToDoViewController
+ if (segue.identifier == "EditToDo") {
+ let cell = sender as UITableViewCell
+ let tableView = self.view as UITableView
+ let index = tableView.indexPathForCell(cell)! as NSIndexPath
+ let toDoEntity = self.toDoItems[index.row] as ToDoEntity
+
+ toDoController.toDoEntity = toDoEntity
+ }
+ toDoController.toDoDelegate = self
+ }
+
+ override func reloadInputViews() {
+ loadToDoItems()
+ tableView.reloadData()
+ super.reloadInputViews()
+ }
+}
+
diff --git a/session-4/.gitignore b/session-4/.gitignore
new file mode 100644
index 0000000..d4f69e4
--- /dev/null
+++ b/session-4/.gitignore
@@ -0,0 +1,3 @@
+DerivedData
+xcuserdata
+xcshareddata
\ No newline at end of file
diff --git a/session-4/Swiftly-Session-4.pdf b/session-4/Swiftly-Session-4.pdf
new file mode 100644
index 0000000..27115b4
Binary files /dev/null and b/session-4/Swiftly-Session-4.pdf differ
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo.xcodeproj/project.pbxproj b/session-4/SwiftlyToDo/SwiftlyToDo.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..8543e7c
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo.xcodeproj/project.pbxproj
@@ -0,0 +1,451 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 914FB6071A016BDB00FFBB87 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914FB6061A016BDB00FFBB87 /* AppDelegate.swift */; };
+ 914FB60A1A016BDB00FFBB87 /* SwiftlyToDo.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 914FB6081A016BDB00FFBB87 /* SwiftlyToDo.xcdatamodeld */; };
+ 914FB60C1A016BDB00FFBB87 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914FB60B1A016BDB00FFBB87 /* ViewController.swift */; };
+ 914FB60F1A016BDB00FFBB87 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 914FB60D1A016BDB00FFBB87 /* Main.storyboard */; };
+ 914FB6111A016BDB00FFBB87 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 914FB6101A016BDB00FFBB87 /* Images.xcassets */; };
+ 914FB6141A016BDB00FFBB87 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 914FB6121A016BDB00FFBB87 /* LaunchScreen.xib */; };
+ 914FB6201A016BDB00FFBB87 /* SwiftlyToDoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914FB61F1A016BDB00FFBB87 /* SwiftlyToDoTests.swift */; };
+ 914FB62A1A01827700FFBB87 /* ToDoItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 914FB6291A01827700FFBB87 /* ToDoItemViewController.swift */; };
+ 916448DC1A1C9A34006F95CF /* ToDoViewControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 916448DB1A1C9A34006F95CF /* ToDoViewControllerDelegate.swift */; };
+ 91FB742F1A1D22BC004CBC45 /* ToDoEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 91FB742E1A1D22BC004CBC45 /* ToDoEntity.swift */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ 914FB61A1A016BDB00FFBB87 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 914FB5F91A016BDB00FFBB87 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 914FB6001A016BDB00FFBB87;
+ remoteInfo = SwiftlyToDo;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+ 914FB6011A016BDB00FFBB87 /* SwiftlyToDo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftlyToDo.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 914FB6051A016BDB00FFBB87 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ 914FB6061A016BDB00FFBB87 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
+ 914FB6091A016BDB00FFBB87 /* SwiftlyToDo.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = SwiftlyToDo.xcdatamodel; sourceTree = ""; };
+ 914FB60B1A016BDB00FFBB87 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
+ 914FB60E1A016BDB00FFBB87 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
+ 914FB6101A016BDB00FFBB87 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
+ 914FB6131A016BDB00FFBB87 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
+ 914FB6191A016BDB00FFBB87 /* SwiftlyToDoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftlyToDoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 914FB61E1A016BDB00FFBB87 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ 914FB61F1A016BDB00FFBB87 /* SwiftlyToDoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftlyToDoTests.swift; sourceTree = ""; };
+ 914FB6291A01827700FFBB87 /* ToDoItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToDoItemViewController.swift; sourceTree = ""; };
+ 916448DB1A1C9A34006F95CF /* ToDoViewControllerDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToDoViewControllerDelegate.swift; sourceTree = ""; };
+ 91FB742E1A1D22BC004CBC45 /* ToDoEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToDoEntity.swift; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 914FB5FE1A016BDB00FFBB87 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 914FB6161A016BDB00FFBB87 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 914FB5F81A016BDB00FFBB87 = {
+ isa = PBXGroup;
+ children = (
+ 914FB6031A016BDB00FFBB87 /* SwiftlyToDo */,
+ 914FB61C1A016BDB00FFBB87 /* SwiftlyToDoTests */,
+ 914FB6021A016BDB00FFBB87 /* Products */,
+ );
+ sourceTree = "";
+ };
+ 914FB6021A016BDB00FFBB87 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 914FB6011A016BDB00FFBB87 /* SwiftlyToDo.app */,
+ 914FB6191A016BDB00FFBB87 /* SwiftlyToDoTests.xctest */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 914FB6031A016BDB00FFBB87 /* SwiftlyToDo */ = {
+ isa = PBXGroup;
+ children = (
+ 914FB6061A016BDB00FFBB87 /* AppDelegate.swift */,
+ 914FB6291A01827700FFBB87 /* ToDoItemViewController.swift */,
+ 914FB60B1A016BDB00FFBB87 /* ViewController.swift */,
+ 916448DB1A1C9A34006F95CF /* ToDoViewControllerDelegate.swift */,
+ 914FB60D1A016BDB00FFBB87 /* Main.storyboard */,
+ 914FB6101A016BDB00FFBB87 /* Images.xcassets */,
+ 914FB6121A016BDB00FFBB87 /* LaunchScreen.xib */,
+ 914FB6081A016BDB00FFBB87 /* SwiftlyToDo.xcdatamodeld */,
+ 91FB742E1A1D22BC004CBC45 /* ToDoEntity.swift */,
+ 914FB6041A016BDB00FFBB87 /* Supporting Files */,
+ );
+ path = SwiftlyToDo;
+ sourceTree = "";
+ };
+ 914FB6041A016BDB00FFBB87 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 914FB6051A016BDB00FFBB87 /* Info.plist */,
+ );
+ name = "Supporting Files";
+ sourceTree = "";
+ };
+ 914FB61C1A016BDB00FFBB87 /* SwiftlyToDoTests */ = {
+ isa = PBXGroup;
+ children = (
+ 914FB61F1A016BDB00FFBB87 /* SwiftlyToDoTests.swift */,
+ 914FB61D1A016BDB00FFBB87 /* Supporting Files */,
+ );
+ path = SwiftlyToDoTests;
+ sourceTree = "";
+ };
+ 914FB61D1A016BDB00FFBB87 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 914FB61E1A016BDB00FFBB87 /* Info.plist */,
+ );
+ name = "Supporting Files";
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 914FB6001A016BDB00FFBB87 /* SwiftlyToDo */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 914FB6231A016BDB00FFBB87 /* Build configuration list for PBXNativeTarget "SwiftlyToDo" */;
+ buildPhases = (
+ 914FB5FD1A016BDB00FFBB87 /* Sources */,
+ 914FB5FE1A016BDB00FFBB87 /* Frameworks */,
+ 914FB5FF1A016BDB00FFBB87 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = SwiftlyToDo;
+ productName = SwiftlyToDo;
+ productReference = 914FB6011A016BDB00FFBB87 /* SwiftlyToDo.app */;
+ productType = "com.apple.product-type.application";
+ };
+ 914FB6181A016BDB00FFBB87 /* SwiftlyToDoTests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 914FB6261A016BDB00FFBB87 /* Build configuration list for PBXNativeTarget "SwiftlyToDoTests" */;
+ buildPhases = (
+ 914FB6151A016BDB00FFBB87 /* Sources */,
+ 914FB6161A016BDB00FFBB87 /* Frameworks */,
+ 914FB6171A016BDB00FFBB87 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 914FB61B1A016BDB00FFBB87 /* PBXTargetDependency */,
+ );
+ name = SwiftlyToDoTests;
+ productName = SwiftlyToDoTests;
+ productReference = 914FB6191A016BDB00FFBB87 /* SwiftlyToDoTests.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 914FB5F91A016BDB00FFBB87 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0610;
+ ORGANIZATIONNAME = "Ciaran O hUallachain";
+ TargetAttributes = {
+ 914FB6001A016BDB00FFBB87 = {
+ CreatedOnToolsVersion = 6.1;
+ };
+ 914FB6181A016BDB00FFBB87 = {
+ CreatedOnToolsVersion = 6.1;
+ TestTargetID = 914FB6001A016BDB00FFBB87;
+ };
+ };
+ };
+ buildConfigurationList = 914FB5FC1A016BDB00FFBB87 /* Build configuration list for PBXProject "SwiftlyToDo" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 914FB5F81A016BDB00FFBB87;
+ productRefGroup = 914FB6021A016BDB00FFBB87 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 914FB6001A016BDB00FFBB87 /* SwiftlyToDo */,
+ 914FB6181A016BDB00FFBB87 /* SwiftlyToDoTests */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 914FB5FF1A016BDB00FFBB87 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 914FB60F1A016BDB00FFBB87 /* Main.storyboard in Resources */,
+ 914FB6141A016BDB00FFBB87 /* LaunchScreen.xib in Resources */,
+ 914FB6111A016BDB00FFBB87 /* Images.xcassets in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 914FB6171A016BDB00FFBB87 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 914FB5FD1A016BDB00FFBB87 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 914FB60C1A016BDB00FFBB87 /* ViewController.swift in Sources */,
+ 914FB60A1A016BDB00FFBB87 /* SwiftlyToDo.xcdatamodeld in Sources */,
+ 914FB6071A016BDB00FFBB87 /* AppDelegate.swift in Sources */,
+ 91FB742F1A1D22BC004CBC45 /* ToDoEntity.swift in Sources */,
+ 916448DC1A1C9A34006F95CF /* ToDoViewControllerDelegate.swift in Sources */,
+ 914FB62A1A01827700FFBB87 /* ToDoItemViewController.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 914FB6151A016BDB00FFBB87 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 914FB6201A016BDB00FFBB87 /* SwiftlyToDoTests.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 914FB61B1A016BDB00FFBB87 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 914FB6001A016BDB00FFBB87 /* SwiftlyToDo */;
+ targetProxy = 914FB61A1A016BDB00FFBB87 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin PBXVariantGroup section */
+ 914FB60D1A016BDB00FFBB87 /* Main.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 914FB60E1A016BDB00FFBB87 /* Base */,
+ );
+ name = Main.storyboard;
+ sourceTree = "";
+ };
+ 914FB6121A016BDB00FFBB87 /* LaunchScreen.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 914FB6131A016BDB00FFBB87 /* Base */,
+ );
+ name = LaunchScreen.xib;
+ sourceTree = "";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 914FB6211A016BDB00FFBB87 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.1;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ };
+ name = Debug;
+ };
+ 914FB6221A016BDB00FFBB87 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.1;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 914FB6241A016BDB00FFBB87 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ INFOPLIST_FILE = SwiftlyToDo/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 914FB6251A016BDB00FFBB87 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ INFOPLIST_FILE = SwiftlyToDo/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+ 914FB6271A016BDB00FFBB87 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ BUNDLE_LOADER = "$(TEST_HOST)";
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(SDKROOT)/Developer/Library/Frameworks",
+ "$(inherited)",
+ );
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ INFOPLIST_FILE = SwiftlyToDoTests/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftlyToDo.app/SwiftlyToDo";
+ };
+ name = Debug;
+ };
+ 914FB6281A016BDB00FFBB87 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ BUNDLE_LOADER = "$(TEST_HOST)";
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(SDKROOT)/Developer/Library/Frameworks",
+ "$(inherited)",
+ );
+ INFOPLIST_FILE = SwiftlyToDoTests/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftlyToDo.app/SwiftlyToDo";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 914FB5FC1A016BDB00FFBB87 /* Build configuration list for PBXProject "SwiftlyToDo" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 914FB6211A016BDB00FFBB87 /* Debug */,
+ 914FB6221A016BDB00FFBB87 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 914FB6231A016BDB00FFBB87 /* Build configuration list for PBXNativeTarget "SwiftlyToDo" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 914FB6241A016BDB00FFBB87 /* Debug */,
+ 914FB6251A016BDB00FFBB87 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 914FB6261A016BDB00FFBB87 /* Build configuration list for PBXNativeTarget "SwiftlyToDoTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 914FB6271A016BDB00FFBB87 /* Debug */,
+ 914FB6281A016BDB00FFBB87 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+
+/* Begin XCVersionGroup section */
+ 914FB6081A016BDB00FFBB87 /* SwiftlyToDo.xcdatamodeld */ = {
+ isa = XCVersionGroup;
+ children = (
+ 914FB6091A016BDB00FFBB87 /* SwiftlyToDo.xcdatamodel */,
+ );
+ currentVersion = 914FB6091A016BDB00FFBB87 /* SwiftlyToDo.xcdatamodel */;
+ path = SwiftlyToDo.xcdatamodeld;
+ sourceTree = "";
+ versionGroupType = wrapper.xcdatamodel;
+ };
+/* End XCVersionGroup section */
+ };
+ rootObject = 914FB5F91A016BDB00FFBB87 /* Project object */;
+}
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/session-4/SwiftlyToDo/SwiftlyToDo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..081dd51
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/AppDelegate.swift b/session-4/SwiftlyToDo/SwiftlyToDo/AppDelegate.swift
new file mode 100644
index 0000000..54adc14
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/AppDelegate.swift
@@ -0,0 +1,111 @@
+//
+// AppDelegate.swift
+// SwiftlyToDo
+//
+// Created by Ciaran O hUallachain on 29/10/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import UIKit
+import CoreData
+
+@UIApplicationMain
+class AppDelegate: UIResponder, UIApplicationDelegate {
+
+ var window: UIWindow?
+
+
+ func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
+ // Override point for customization after application launch.
+ return true
+ }
+
+ func applicationWillResignActive(application: UIApplication) {
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+ }
+
+ func applicationDidEnterBackground(application: UIApplication) {
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+ }
+
+ func applicationWillEnterForeground(application: UIApplication) {
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+ }
+
+ func applicationDidBecomeActive(application: UIApplication) {
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+ }
+
+ func applicationWillTerminate(application: UIApplication) {
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+ // Saves changes in the application's managed object context before the application terminates.
+ self.saveContext()
+ }
+
+ // MARK: - Core Data stack
+
+ lazy var applicationDocumentsDirectory: NSURL = {
+ // The directory the application uses to store the Core Data store file. This code uses a directory named "com.ciaranoh.SwiftlyToDo" in the application's documents Application Support directory.
+ let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
+ return urls[urls.count-1] as NSURL
+ }()
+
+ lazy var managedObjectModel: NSManagedObjectModel = {
+ // The managed object model for the application. This property is not optional. It is a fatal error for the application not to be able to find and load its model.
+ let modelURL = NSBundle.mainBundle().URLForResource("SwiftlyToDo", withExtension: "momd")!
+ return NSManagedObjectModel(contentsOfURL: modelURL)!
+ }()
+
+ lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = {
+ // The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail.
+ // Create the coordinator and store
+ var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
+ let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("SwiftlyToDo.sqlite")
+ var error: NSError? = nil
+ var failureReason = "There was an error creating or loading the application's saved data."
+ if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil {
+ coordinator = nil
+ // Report any error we got.
+ let dict = NSMutableDictionary()
+ dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
+ dict[NSLocalizedFailureReasonErrorKey] = failureReason
+ dict[NSUnderlyingErrorKey] = error
+ error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
+ // Replace this with code to handle the error appropriately.
+ // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
+ NSLog("Unresolved error \(error), \(error!.userInfo)")
+ abort()
+ }
+
+ return coordinator
+ }()
+
+ lazy var managedObjectContext: NSManagedObjectContext? = {
+ // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail.
+ let coordinator = self.persistentStoreCoordinator
+ if coordinator == nil {
+ return nil
+ }
+ var managedObjectContext = NSManagedObjectContext()
+ managedObjectContext.persistentStoreCoordinator = coordinator
+ return managedObjectContext
+ }()
+
+ // MARK: - Core Data Saving support
+
+ func saveContext () {
+ if let moc = self.managedObjectContext {
+ var error: NSError? = nil
+ if moc.hasChanges && !moc.save(&error) {
+ // Replace this implementation with code to handle the error appropriately.
+ // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
+ NSLog("Unresolved error \(error), \(error!.userInfo)")
+ abort()
+ }
+ }
+ }
+
+}
+
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/Base.lproj/LaunchScreen.xib b/session-4/SwiftlyToDo/SwiftlyToDo/Base.lproj/LaunchScreen.xib
new file mode 100644
index 0000000..ebf2dd0
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/Base.lproj/LaunchScreen.xib
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/Base.lproj/Main.storyboard b/session-4/SwiftlyToDo/SwiftlyToDo/Base.lproj/Main.storyboard
new file mode 100644
index 0000000..ec862b0
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/Base.lproj/Main.storyboard
@@ -0,0 +1,139 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/Images.xcassets/AppIcon.appiconset/Contents.json b/session-4/SwiftlyToDo/SwiftlyToDo/Images.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 0000000..118c98f
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/Images.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "images" : [
+ {
+ "idiom" : "iphone",
+ "size" : "29x29",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "29x29",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "40x40",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "40x40",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "60x60",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "60x60",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/Info.plist b/session-4/SwiftlyToDo/SwiftlyToDo/Info.plist
new file mode 100644
index 0000000..15aee61
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/Info.plist
@@ -0,0 +1,40 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ com.ciaranoh.$(PRODUCT_NAME:rfc1034identifier)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1
+ LSRequiresIPhoneOS
+
+ UILaunchStoryboardName
+ LaunchScreen
+ UIMainStoryboardFile
+ Main
+ UIRequiredDeviceCapabilities
+
+ armv7
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+
+
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/SwiftlyToDo.xcdatamodeld/.xccurrentversion b/session-4/SwiftlyToDo/SwiftlyToDo/SwiftlyToDo.xcdatamodeld/.xccurrentversion
new file mode 100644
index 0000000..449451f
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/SwiftlyToDo.xcdatamodeld/.xccurrentversion
@@ -0,0 +1,8 @@
+
+
+
+
+ _XCCurrentVersionName
+ SwiftlyToDo.xcdatamodel
+
+
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/SwiftlyToDo.xcdatamodeld/SwiftlyToDo.xcdatamodel/contents b/session-4/SwiftlyToDo/SwiftlyToDo/SwiftlyToDo.xcdatamodeld/SwiftlyToDo.xcdatamodel/contents
new file mode 100644
index 0000000..fa44028
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/SwiftlyToDo.xcdatamodeld/SwiftlyToDo.xcdatamodel/contents
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/ToDoEntity.swift b/session-4/SwiftlyToDo/SwiftlyToDo/ToDoEntity.swift
new file mode 100644
index 0000000..c5e1b4c
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/ToDoEntity.swift
@@ -0,0 +1,18 @@
+//
+// ToDoEntity.swift
+// SwiftlyToDo
+//
+// Created by Ciaran O hUallachain on 19/11/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import Foundation
+import CoreData
+
+class ToDoEntity: NSManagedObject {
+
+ @NSManaged var toDoTitle: String
+ @NSManaged var toDoDescription: String
+ @NSManaged var toDoComplete: NSNumber
+
+}
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/ToDoItemViewController.swift b/session-4/SwiftlyToDo/SwiftlyToDo/ToDoItemViewController.swift
new file mode 100644
index 0000000..c7b3d4c
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/ToDoItemViewController.swift
@@ -0,0 +1,74 @@
+//
+// ToDoItemViewController.swift
+// SwiftlyToDo
+//
+// Created by Ciaran O hUallachain on 29/10/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import UIKit
+import CoreData
+
+class ToDoItemViewController: UIViewController {
+ @IBOutlet var titleTextField: UITextField!
+ @IBOutlet var statusSwitch: UISwitch!
+ @IBOutlet var descriptionTextView: UITextView!
+
+ var toDoItem: ToDoEntity? = nil
+ var toDoSaveDelegate: ToDoViewControllerDelegate? = nil
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ // Do any additional setup after loading the view.
+ }
+
+ override func didReceiveMemoryWarning() {
+ super.didReceiveMemoryWarning()
+ // Dispose of any resources that can be recreated.
+ }
+
+ override func viewWillAppear(animated: Bool) {
+ if let item: ToDoEntity = self.toDoItem {
+ self.titleTextField.text = item.toDoTitle
+ self.descriptionTextView.text = item.toDoDescription
+ self.statusSwitch.on = item.toDoComplete as Bool
+ } else {
+ self.statusSwitch.on = false
+ }
+ super.viewWillAppear(animated)
+ }
+
+ @IBAction func save() {
+ let titleText: NSString = self.titleTextField.text
+ if (titleText.length == 0) {
+ return
+ }
+
+ let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
+ let context: NSManagedObjectContext = appDelegate.managedObjectContext!
+
+ if ((self.toDoItem) == nil) {
+ self.toDoItem = (NSEntityDescription.insertNewObjectForEntityForName("ToDoEntity", inManagedObjectContext:
+ context) as ToDoEntity)
+ }
+
+ self.toDoItem?.toDoTitle = titleText
+ self.toDoItem?.toDoDescription = self.descriptionTextView.text
+ self.toDoItem?.toDoComplete = self.statusSwitch.on
+
+ self.toDoSaveDelegate?.saveToDoItem(self.toDoItem!)
+ }
+
+
+ /*
+ // 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.
+ }
+ */
+
+}
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/ToDoViewControllerDelegate.swift b/session-4/SwiftlyToDo/SwiftlyToDo/ToDoViewControllerDelegate.swift
new file mode 100644
index 0000000..b7f0722
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/ToDoViewControllerDelegate.swift
@@ -0,0 +1,13 @@
+//
+// ToDoViewControllerDelegate.swift
+// SwiftlyToDo
+//
+// Created by Ciaran O hUallachain on 19/11/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import Foundation
+
+protocol ToDoViewControllerDelegate {
+ func saveToDoItem(toDoEntity: ToDoEntity);
+}
diff --git a/session-4/SwiftlyToDo/SwiftlyToDo/ViewController.swift b/session-4/SwiftlyToDo/SwiftlyToDo/ViewController.swift
new file mode 100644
index 0000000..ef7cf57
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDo/ViewController.swift
@@ -0,0 +1,124 @@
+//
+// ViewController.swift
+// SwiftlyToDo
+//
+// Created by Ciaran O hUallachain on 29/10/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import UIKit
+import CoreData
+
+class ViewController: UITableViewController, ToDoViewControllerDelegate {
+ var toDoItems: [ToDoEntity] = []
+ @IBOutlet var editButton: UIBarButtonItem! = nil
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+ self.loadToDoData()
+ // 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 self.toDoItems.count
+ }
+
+ override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
+ let cell = tableView.dequeueReusableCellWithIdentifier("ToDoCell") as UITableViewCell
+ let toDoItem = self.toDoItems[indexPath.row]
+ cell.textLabel.text = toDoItem.toDoTitle
+ cell.accessoryType = toDoItem.toDoComplete as Bool ? UITableViewCellAccessoryType.Checkmark : UITableViewCellAccessoryType.None
+ return cell
+ }
+
+ override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
+ println(indexPath.description)
+ tableView.deselectRowAtIndexPath(indexPath, animated: true)
+ }
+
+ func saveToDoItem(toDoItem: ToDoEntity) {
+ let testItems = NSSet(array: self.toDoItems)
+ if (!testItems.containsObject(toDoItem)) {
+ self.toDoItems.append(toDoItem)
+ }
+
+ let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
+ let context: NSManagedObjectContext = appDelegate.managedObjectContext!
+
+ var error: NSError? = nil
+ var success = context.save(&error)
+
+ if (success) {
+ self.loadToDoData()
+ self.tableView.reloadData()
+ self.navigationController?.popViewControllerAnimated(true)
+ }
+
+ }
+
+ override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
+ let toDoController: ToDoItemViewController = segue.destinationViewController as ToDoItemViewController
+ if (segue.identifier == "ShowToDoItem") {
+ let cell = sender as UITableViewCell
+ let tableView = self.view as UITableView
+ let indexPath = tableView.indexPathForCell(cell)! as NSIndexPath
+ let toDoItem = self.toDoItems[indexPath.row]
+
+ toDoController.toDoItem = toDoItem
+ }
+ toDoController.toDoSaveDelegate = self
+ }
+
+ @IBAction func editTable(sender: UIBarButtonItem) {
+ self.setEditing(!self.tableView.editing, animated: true)
+ }
+
+ override func setEditing(editing: Bool, animated: Bool) {
+ self.editButton.title = editing ? "Done" : "Edit"
+ super.setEditing(editing, animated: animated)
+ }
+
+ override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
+ return true
+ }
+
+ override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
+ if (editingStyle == UITableViewCellEditingStyle.Delete) {
+ let toDoItem = self.toDoItems[indexPath.row]
+ let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
+ let context: NSManagedObjectContext = appDelegate.managedObjectContext!
+
+ context.deleteObject(toDoItem)
+
+ var error: NSError? = nil
+ var success = context.save(&error)
+
+ if (success) {
+ self.loadToDoData()
+ self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Left)
+ }
+ }
+ }
+
+ func loadToDoData() {
+ let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
+ let context: NSManagedObjectContext = appDelegate.managedObjectContext!
+
+ var error: NSError? = nil
+ var fetchRequest: NSFetchRequest = NSFetchRequest(entityName: "ToDoEntity")
+ fetchRequest.resultType = NSFetchRequestResultType.ManagedObjectResultType
+ let results: NSArray = context.executeFetchRequest(fetchRequest, error: &error)!
+
+ self.toDoItems = [ToDoEntity]()
+ for data in results {
+ var toDoEntity = data as ToDoEntity
+ self.toDoItems.append(toDoEntity)
+ }
+ }
+}
+
diff --git a/session-4/SwiftlyToDo/SwiftlyToDoTests/Info.plist b/session-4/SwiftlyToDo/SwiftlyToDoTests/Info.plist
new file mode 100644
index 0000000..99b8fe6
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDoTests/Info.plist
@@ -0,0 +1,24 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ com.ciaranoh.$(PRODUCT_NAME:rfc1034identifier)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ BNDL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1
+
+
diff --git a/session-4/SwiftlyToDo/SwiftlyToDoTests/SwiftlyToDoTests.swift b/session-4/SwiftlyToDo/SwiftlyToDoTests/SwiftlyToDoTests.swift
new file mode 100644
index 0000000..00e57cc
--- /dev/null
+++ b/session-4/SwiftlyToDo/SwiftlyToDoTests/SwiftlyToDoTests.swift
@@ -0,0 +1,36 @@
+//
+// SwiftlyToDoTests.swift
+// SwiftlyToDoTests
+//
+// Created by Ciaran O hUallachain on 29/10/2014.
+// Copyright (c) 2014 Ciaran O hUallachain. All rights reserved.
+//
+
+import UIKit
+import XCTest
+
+class SwiftlyToDoTests: XCTestCase {
+
+ override func setUp() {
+ super.setUp()
+ // Put setup code here. This method is called before the invocation of each test method in the class.
+ }
+
+ override func tearDown() {
+ // Put teardown code here. This method is called after the invocation of each test method in the class.
+ super.tearDown()
+ }
+
+ func testExample() {
+ // This is an example of a functional test case.
+ XCTAssert(true, "Pass")
+ }
+
+ func testPerformanceExample() {
+ // This is an example of a performance test case.
+ self.measureBlock() {
+ // Put the code you want to measure the time of here.
+ }
+ }
+
+}