1
- //
2
- // AppDelegate.swift
3
- // PeristenceDemo
4
- //
5
- // Created by Ben Sandofsky on 3/14/15.
6
- // Copyright (c) 2015 CodePath. All rights reserved.
7
- //
8
-
9
1
import UIKit
10
2
import CoreData
11
3
@@ -23,27 +15,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
23
15
return true
24
16
}
25
17
26
- func applicationWillResignActive( application: UIApplication ) {
27
-
28
- }
29
-
30
18
func applicationDidEnterBackground( application: UIApplication ) {
31
19
self . saveToDisk ( )
32
20
}
33
21
34
- func applicationWillEnterForeground( application: UIApplication ) {
35
- // 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.
36
- }
37
-
38
- func applicationDidBecomeActive( application: UIApplication ) {
39
- // 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.
40
- }
41
-
42
- func applicationWillTerminate( application: UIApplication ) {
43
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
44
- }
45
-
46
-
47
22
private func itemsFromDisk( ) -> [ TodoItem ] {
48
23
return Array ( )
49
24
}
@@ -53,21 +28,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
53
28
}
54
29
55
30
private var pathForKeyedArchive : String {
56
- get {
57
- return ( NSSearchPathForDirectoriesInDomains ( . DocumentDirectory, . UserDomainMask, true ) . first! as NSString ) . stringByAppendingPathComponent ( " archive.bin " )
58
- }
31
+ return ( NSSearchPathForDirectoriesInDomains ( . DocumentDirectory, . UserDomainMask, true ) . first! as NSString ) . stringByAppendingPathComponent ( " archive.bin " )
59
32
}
60
33
61
34
// MARK: Core Data Stack
35
+ var persistentStoreCoordinator : NSPersistentStoreCoordinator !
36
+ var managedObjectContext : NSManagedObjectContext !
62
37
private var pathForCoreDataStore : String {
63
38
get {
64
39
return ( NSSearchPathForDirectoriesInDomains ( . DocumentDirectory, . UserDomainMask, true ) . first! as NSString ) . stringByAppendingPathComponent ( " archive.sqlite " )
65
40
}
66
41
}
67
42
68
- var persistentStoreCoordinator : NSPersistentStoreCoordinator !
69
- var managedObjectContext : NSManagedObjectContext !
70
-
71
43
private func setupCoreDataStack( ) {
72
44
let modelURL = NSBundle . mainBundle ( ) . URLForResource ( " Model " , withExtension: " momd " ) !
73
45
let model = NSManagedObjectModel ( contentsOfURL: modelURL) !
0 commit comments