- Notifications
You must be signed in to change notification settings - Fork3
A static library project that simplifies Core Data.
License
GabrielMassana/CoreDataFullStack-iOS
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Easiest way to build a Core Data full stack.
This project stack consists of two independent managed object contexts which are both connected to the same persistent store coordinator.
The Core Data stack used follows the Florian Kugler's third example fromthis article.
Florian Kugler's investigation shows how this Core Data Stack is the faster one.
Core data make sense to use with an FRC. The project comes with the basic FRC implementation for a table and collection view.
TODO: The project will have a full suite to access the objects.
platform:ios,'8.0'pod'CoreDataFullStack','~> 0.4'
Then, run the following command:
$ pod install
Drag into your project the folder/CoreDataFullStack-iOS. That's all.
To modify the database (insert new object, delete, update) access via the backgroundbackgroundManagedObjectContext.
To retrieve data to be shown in the UI access via the MainThreadmanagedObjectContext
To avoid crossing threads useperformBlockAndWait:^ with thebackgroundManagedObjectContext
[[CDFCoreDataManagersharedInstance].backgroundManagedObjectContextperformBlockAndWait:^ {// Insert// Delete// Update }
Go to Edit Scheme.../ Arguments / Arguments Passed On Launch and add:-com.apple.CoreData.ConcurrencyDebug 1
This line will tell you if you are crossing threads in your app.
To avoid problems be totally sure that your app is not crossing threads.
// AppDelegate.m#import"CoreDataFullStack.h"@interfaceAppDelegate () <CDFCoreDataManagerDelegate>- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [CDFCoreDataManagersharedInstance].delegate = self;returnYES;}#pragma mark - CDFCoreDataManagerDelegate- (NSString *)coreDataModelName{return@"ModelName";}
Use CoreData system. It is really easy.
[[CDFCoreDataManagersharedInstance].backgroundManagedObjectContextperformBlockAndWait:^ { CDFHouse *firstHouse = [NSEntityDescriptioninsertNewObjectForEntityForName:NSStringFromClass([CDFHouseclass])inManagedObjectContext:[CDFCoreDataManagersharedInstance].backgroundManagedObjectContext]; firstHouse.houseID =@"0"; firstHouse.town =@"London"; CDFPerson *firstPerson = [NSEntityDescriptioninsertNewObjectForEntityForName:NSStringFromClass([CDFPersonclass])inManagedObjectContext:[CDFCoreDataManagersharedInstance].backgroundManagedObjectContext]; firstPerson.personID =@"0"; firstPerson.name =@"John"; firstPerson.house = firstHouse; [[CDFCoreDataManagersharedInstance].backgroundManagedObjectContextsave:nil]; }];
NSArray *entries = [CDFRetrievalServiceretrieveEntriesForEntityClass:[CDFHouseclass]managedObjectContext:[CDFCoreDataManagersharedInstance].managedObjectContext];
[[CDFCoreDataManagersharedInstance].backgroundManagedObjectContextperformBlockAndWait:^ { [CDFDeletionServicedeleteEntriesForEntityClass:[CDFHouseclass]saveAfterDeletion:YESmanagedObjectContext:[CDFCoreDataManagersharedInstance].backgroundManagedObjectContext]; }];
NSArray *entries = [CDFRetrievalServiceretrieveEntriesForEntityClass:[CDFHouseclass]managedObjectContext:[CDFCoreDataManagersharedInstance].managedObjectContext];
CoreDataFullStack-iOS is released under the MIT license. Please see the file called LICENSE.
$ git tag -a 0.4.0 -m'Version 0.4.0'$ git push --tagsGabriel Massana
##Found an issue?
Please open anew Issue here if you run into a problem specific to CoreDataFullStack-iOS, have a feature request, or want to share a comment.
About
A static library project that simplifies Core Data.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
