Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use core data #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
120 changes: 114 additions & 6 deletions Todoey.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@
objects = {

/* Begin PBXBuildFile section */
0CE0D8C0BD1A47BF8F0B1D60 /* Pods_Todoey.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1761A21657AB8618B197D056 /* Pods_Todoey.framework */; };
9D74BAA22469DDD7006E5DF5 /* DataModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 9D74BAA02469DDD7006E5DF5 /* DataModel.xcdatamodeld */; };
9D7DA83E246D064000AD882D /* CategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D7DA83D246D064000AD882D /* CategoryViewController.swift */; };
EB2BE4FA239524DB00FB933B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB2BE4F9239524DB00FB933B /* AppDelegate.swift */; };
EB2BE4FE239524DB00FB933B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB2BE4FD239524DB00FB933B /* ViewController.swift */; };
EB2BE4FE239524DB00FB933B /* TodoListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB2BE4FD239524DB00FB933B /* TodoListViewController.swift */; };
EB2BE501239524DB00FB933B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EB2BE4FF239524DB00FB933B /* Main.storyboard */; };
EB2BE503239524DC00FB933B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EB2BE502239524DC00FB933B /* Assets.xcassets */; };
EB2BE506239524DC00FB933B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EB2BE504239524DC00FB933B /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
0A17296F838C29D43D20A9E0 /* Pods-Todoey.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Todoey.release.xcconfig"; path = "Target Support Files/Pods-Todoey/Pods-Todoey.release.xcconfig"; sourceTree = "<group>"; };
1761A21657AB8618B197D056 /* Pods_Todoey.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Todoey.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9D74BAA12469DDD7006E5DF5 /* DataModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DataModel.xcdatamodel; sourceTree = "<group>"; };
9D7DA83D246D064000AD882D /* CategoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryViewController.swift; sourceTree = "<group>"; };
9FEE6652EA4BF2DDFEBFFA8E /* Pods-Todoey.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Todoey.debug.xcconfig"; path = "Target Support Files/Pods-Todoey/Pods-Todoey.debug.xcconfig"; sourceTree = "<group>"; };
EB2BE4F6239524DB00FB933B /* Todoey.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Todoey.app; sourceTree = BUILT_PRODUCTS_DIR; };
EB2BE4F9239524DB00FB933B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
EB2BE4FD239524DB00FB933B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
EB2BE4FD239524DB00FB933B /* TodoListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoListViewController.swift; sourceTree = "<group>"; };
EB2BE500239524DB00FB933B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
EB2BE502239524DC00FB933B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
EB2BE505239524DC00FB933B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
Expand All @@ -29,17 +37,55 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0CE0D8C0BD1A47BF8F0B1D60 /* Pods_Todoey.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
7FED3DF95005E8AEE77E0ACE /* Frameworks */ = {
isa = PBXGroup;
children = (
1761A21657AB8618B197D056 /* Pods_Todoey.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
9D74BA9B2469B4C9006E5DF5 /* Data Model */ = {
isa = PBXGroup;
children = (
9D74BAA02469DDD7006E5DF5 /* DataModel.xcdatamodeld */,
);
path = "Data Model";
sourceTree = "<group>";
};
9D74BA9C2469B4D3006E5DF5 /* Controllers */ = {
isa = PBXGroup;
children = (
EB2BE4FD239524DB00FB933B /* TodoListViewController.swift */,
9D7DA83D246D064000AD882D /* CategoryViewController.swift */,
);
path = Controllers;
sourceTree = "<group>";
};
B045CBD33A5C732FFFFAFB43 /* Pods */ = {
isa = PBXGroup;
children = (
9FEE6652EA4BF2DDFEBFFA8E /* Pods-Todoey.debug.xcconfig */,
0A17296F838C29D43D20A9E0 /* Pods-Todoey.release.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
EB2BE4ED239524DB00FB933B = {
isa = PBXGroup;
children = (
EB2BE4F8239524DB00FB933B /* Todoey */,
EB2BE4F7239524DB00FB933B /* Products */,
B045CBD33A5C732FFFFAFB43 /* Pods */,
7FED3DF95005E8AEE77E0ACE /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -55,11 +101,12 @@
isa = PBXGroup;
children = (
EB2BE4F9239524DB00FB933B /* AppDelegate.swift */,
EB2BE4FD239524DB00FB933B /* ViewController.swift */,
9D74BA9C2469B4D3006E5DF5 /* Controllers */,
EB2BE4FF239524DB00FB933B /* Main.storyboard */,
EB2BE502239524DC00FB933B /* Assets.xcassets */,
EB2BE504239524DC00FB933B /* LaunchScreen.storyboard */,
EB2BE507239524DC00FB933B /* Info.plist */,
9D74BA9B2469B4C9006E5DF5 /* Data Model */,
);
path = Todoey;
sourceTree = "<group>";
Expand All @@ -71,9 +118,11 @@
isa = PBXNativeTarget;
buildConfigurationList = EB2BE50A239524DC00FB933B /* Build configuration list for PBXNativeTarget "Todoey" */;
buildPhases = (
2FE5AE3D7C9EFC78B5C86DA9 /* [CP] Check Pods Manifest.lock */,
EB2BE4F2239524DB00FB933B /* Sources */,
EB2BE4F3239524DB00FB933B /* Frameworks */,
EB2BE4F4239524DB00FB933B /* Resources */,
15C4C9678707F997B8B479BC /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -130,12 +179,56 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
15C4C9678707F997B8B479BC /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Todoey/Pods-Todoey-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Todoey/Pods-Todoey-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Todoey/Pods-Todoey-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
2FE5AE3D7C9EFC78B5C86DA9 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Todoey-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
EB2BE4F2239524DB00FB933B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EB2BE4FE239524DB00FB933B /* ViewController.swift in Sources */,
9D7DA83E246D064000AD882D /* CategoryViewController.swift in Sources */,
EB2BE4FE239524DB00FB933B /* TodoListViewController.swift in Sources */,
9D74BAA22469DDD7006E5DF5 /* DataModel.xcdatamodeld in Sources */,
EB2BE4FA239524DB00FB933B /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -278,6 +371,7 @@
};
EB2BE50B239524DC00FB933B /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9FEE6652EA4BF2DDFEBFFA8E /* Pods-Todoey.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
Expand All @@ -287,7 +381,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.londonappbrewery.todoey-ios13.Todoey";
PRODUCT_BUNDLE_IDENTIFIER = "com.masunomatiko.todoey-ios13.Todoey";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -296,6 +390,7 @@
};
EB2BE50C239524DC00FB933B /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 0A17296F838C29D43D20A9E0 /* Pods-Todoey.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
Expand All @@ -305,7 +400,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.londonappbrewery.todoey-ios13.Todoey";
PRODUCT_BUNDLE_IDENTIFIER = "com.masunomatiko.todoey-ios13.Todoey";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -334,6 +429,19 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCVersionGroup section */
9D74BAA02469DDD7006E5DF5 /* DataModel.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
9D74BAA12469DDD7006E5DF5 /* DataModel.xcdatamodel */,
);
currentVersion = 9D74BAA12469DDD7006E5DF5 /* DataModel.xcdatamodel */;
path = DataModel.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = EB2BE4EE239524DB00FB933B /* Project object */;
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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>SchemeUserState</key>
<dict>
<key>Todoey.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
10 changes: 10 additions & 0 deletions Todoey.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 35 additions & 21 deletions Todoey/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//
// AppDelegate.swift
// Destini
// Todoey
//
// Created by Philipp Muellauer on 01/09/2015.
// Copyright (c) 2015 London App Brewery. All rights reserved.
// Created by Angela Yu on 16/11/2017.
// Copyright © 2017 Angela Yu. All rights reserved.
//

import UIKit
import CoreData

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -15,32 +16,45 @@ class AppDelegate: UIResponder, UIApplicationDelegate {


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> 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 applicationWillTerminate(_ application: UIApplication) {

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.
self.saveContext()
}

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.

// MARK: - Core Data stack

lazy var persistentContainer: NSPersistentContainer = {

let container = NSPersistentContainer(name: "DataModel")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {

fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()

// MARK: - Core Data Saving support

func saveContext () {
let context = persistentContainer.viewContext
if context.hasChanges {
do {
try context.save()
} catch {

let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

Loading