From 582e53c57da94b9cf3f2da30e905e176c05b0b80 Mon Sep 17 00:00:00 2001 From: AC-MBA Date: Sat, 14 Apr 2012 22:40:31 -0700 Subject: [PATCH 1/2] added sqlite db --- FailedBankCD/CoreDataTutorial2.sqlite | Bin 0 -> 32768 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 FailedBankCD/CoreDataTutorial2.sqlite diff --git a/FailedBankCD/CoreDataTutorial2.sqlite b/FailedBankCD/CoreDataTutorial2.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..0f65b5d20780e92bcc2973c38f3eb0775d92bee7 GIT binary patch literal 32768 zcmeI)Z)h8390%~{$z7V-wY_xEWus_s#X>_@Y??ocqU^4@xLfnDxg>2fFl6gh!`fsd zSKTHksrW_)Dk7p3WWE#e<;00Y=L`2n6!u~-^u^HOa4NnM1Yh|)mrI+3R%CA^@O@}5 z&;5SSbI)_1O9IDp)L4v{EmK~r);3C(93);sDLF37gpdLD>SwQ3>0=e@?C^N2-g5QIGGAr_e zwsMR$&E@o{oL4gQCzQ<8TsZ9K!E{_Vva%Xass6@*+vA&@q>UwKbf-V-&e}DP#p<4} z8SG~G9JFM1zwwhwLTioBhc-AbNcIG;NHRE34-DLQK))T2xh% z3wkn^Di)$lMvogsJsH)OyRv=G4DFoUmF(&&Gq0`|>@=LC`x~m@@l8+DttXl!owMlb z=kA2*Y%5Q3?1k3(bzhq{HZGA$?R&*a^>+i$>cjf9}?Q)TVcVDKm6O|sEfy4cKiIdu4ef7;ZeF9o_?0v;far~@rV3H z=@%mXE&VC|!73;afB*y_009U<00Izz00bZa0SNT0fLowc6!}&V_}1m(TS}Yj|Cfk# zNBUa&P`cE!Cy0qd00Izz00bZa0SG_<0uX=z1bReZ%wFlIKHm`+73a&=g^*gRoDCUP z$udJ@_HutSDez>FCxdn}IA*W;Hb_ue_Q`|N#7CaF593$00Izz00bZa0SG_<0uX=z1R&50 z0;4WB@lzTrmDkNxzRa&z)~ZB2Ox@&>_Hfj+Sd%&t`SbsD_!MD(C=h@E1Rwwb2tWV= z5P$##AOL~;5qM>S-F4<(eJL`lh1Ez%nRzUzs52ogqRgn85}gUhVzKaSRDCoSiJU&S zUaniSv$v>A5Z!&A2L=v!M~dEul7?YbYi6RlYOd$aTD@GY=&NSMDzBB<-YF-Yy>QMf zdJh(phO%i@^QAMJn;UWSd2_w!J+j9UPL%4;nf0Rg!K9Jq$E;gs<%}7tl{U;5sF8bdcygYsV8)M>&Yp?(Q9 CWZxwK literal 0 HcmV?d00001 From 61956cc851fe9e0704d7d3cb6a0c4336a86b054c Mon Sep 17 00:00:00 2001 From: AC-MBA Date: Sun, 15 Apr 2012 00:41:44 -0700 Subject: [PATCH 2/2] loaded preloaded sqlite db --- FailedBankCD.xcodeproj/project.pbxproj | 4 ++++ FailedBankCD/FBCDAppDelegate.m | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/FailedBankCD.xcodeproj/project.pbxproj b/FailedBankCD.xcodeproj/project.pbxproj index 1fd23eb..7d2207a 100644 --- a/FailedBankCD.xcodeproj/project.pbxproj +++ b/FailedBankCD.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4B07960D153A96F4002349B8 /* CoreDataTutorial2.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 4B07960C153A96F4002349B8 /* CoreDataTutorial2.sqlite */; }; 4B7AB8BD151D932E00FB21FA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B7AB8BC151D932E00FB21FA /* UIKit.framework */; }; 4B7AB8BF151D932E00FB21FA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B7AB8BE151D932E00FB21FA /* Foundation.framework */; }; 4B7AB8C1151D932E00FB21FA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B7AB8C0151D932E00FB21FA /* CoreGraphics.framework */; }; @@ -22,6 +23,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 4B07960C153A96F4002349B8 /* CoreDataTutorial2.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = CoreDataTutorial2.sqlite; sourceTree = ""; }; 4B7AB8B8151D932E00FB21FA /* FailedBankCD.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FailedBankCD.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4B7AB8BC151D932E00FB21FA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 4B7AB8BE151D932E00FB21FA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -89,6 +91,7 @@ 4B7AB8C4151D932E00FB21FA /* FailedBankCD */ = { isa = PBXGroup; children = ( + 4B07960C153A96F4002349B8 /* CoreDataTutorial2.sqlite */, 4B7AB8CD151D932E00FB21FA /* FBCDAppDelegate.h */, 4B7AB8CE151D932E00FB21FA /* FBCDAppDelegate.m */, 4B7AB8D0151D932E00FB21FA /* MainStoryboard.storyboard */, @@ -169,6 +172,7 @@ files = ( 4B7AB8C9151D932E00FB21FA /* InfoPlist.strings in Resources */, 4B7AB8D2151D932E00FB21FA /* MainStoryboard.storyboard in Resources */, + 4B07960D153A96F4002349B8 /* CoreDataTutorial2.sqlite in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/FailedBankCD/FBCDAppDelegate.m b/FailedBankCD/FBCDAppDelegate.m index 87762e2..1c2d132 100644 --- a/FailedBankCD/FBCDAppDelegate.m +++ b/FailedBankCD/FBCDAppDelegate.m @@ -140,6 +140,16 @@ - (NSPersistentStoreCoordinator *)persistentStoreCoordinator } NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"FailedBankCD.sqlite"]; + + if (![[NSFileManager defaultManager] fileExistsAtPath:[storeURL path]]) { + NSURL *preloadURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"CoreDataTutorial2" ofType:@"sqlite"]]; + + NSError* err = nil; + + if (![[NSFileManager defaultManager] copyItemAtURL:preloadURL toURL:storeURL error:&err]) { + NSLog(@"Oops, could copy preloaded data"); + } + } NSError *error = nil; __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];