@@ -46,6 +46,7 @@ With the release of XCode 6 the simulator changes the name of the persistence st
4646
4747Add this code to your iOS application:
4848
49+ ### Objective C
4950`````
5051#if !(TARGET_OS_EMBEDDED) // This will work for Mac or Simulator but excludes physical iOS devices
5152- (void) createCoreDataDebugProjectWithType: (NSNumber*) storeFormat storeUrl:(NSString*) storeURL modelFilePath:(NSString*) modelFilePath {
@@ -64,10 +65,33 @@ Add this code to your iOS application:
6465#endif
6566`````
6667
68+ ### Swift
69+
70+ `````
71+ #if !(TARGET_OS_EMBEDDED)
72+ func createCoreDataDebugProjectWithType(storeFormat: NSNumber, storeURL: String, modelFilePath: String) {
73+
74+ var project:NSDictionary = [
75+ "storeFilePath": storeURL,
76+ "storeFormat" : storeFormat,
77+ "modelFilePath": modelFilePath,
78+ "v" : "1"
79+ ]
80+
81+ var projectFile = "/tmp/\(NSBundle.mainBundle().infoDictionary![kCFBundleNameKey]!).cdp"
82+
83+ project.writeToFile(projectFile, atomically: true)
84+ }
85+
86+ #endif
87+ `````
88+
6789Now call that code where you initialize your CoreData persistent store.
6890
6991Something like this:
7092
93+
94+ ### Objective C
7195`````
7296#if !(TARGET_OS_EMBEDDED) // This will work for Mac or Simulator but excludes physical iOS devices
7397#ifdef DEBUG
@@ -77,6 +101,19 @@ Something like this:
77101#endif
78102`````
79103
104+ ### Swift
105+
106+ `````
107+
108+ #if !(TARGET_OS_EMBEDDED) // This will work for Mac or Simulator but excludes physical iOS devices
109+ #if DEBUG
110+ // @(1) is NSSQLiteStoreType
111+ createCoreDataDebugProjectWithType(1, storeURL: persistentStore!.URL!.absoluteString!, modelFilePath: modelUrl.absoluteString!)
112+ #endif
113+ #endif
114+
115+ `````
116+
80117Now you can just open the /tmp/YourAppName.cdp file and it will open CoreDataUtility with your app's data loaded.
81118
82119
0 commit comments