Skip to content

julienfantin/CDStack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CDStack

Simplified CoreData stack management

Rationale

CDStack aims to make it easy to use a simple CoreData configuration, and easier to manage complex setups with possibly asynchronous data stores.

What's commonly described as a CoreData stack usually refers to an instance of NSPersistentStoreCoordinator, its configuration and related objects.

The boilerplate generated by Xcode's CoreData template can be replaced with the following.

@interface MyAppDelegate
@property (strong, nonatomic) CDStack *stack;
@end
@implementation CDAppDelegate
@synthesize stack = _stack;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
	self.stack = [[CDStack alloc] initWithStoreClass:[CDSQLiteStore class]];
    // init app
	return YES;
}

The details of this particular stack are defined on CDSQLiteStore which adopts the CDPersistentStore prorocol and makes for a designated place to define these implementation details.

@protocol CDPersistentStore <NSObject>
@required
+ (NSString *)type;
@optional
+ (NSURL *)url;
+ (NSString *)configuration;
+ (NSDictionary *)options;
@end

To document

  • Threading
    • Block-based fetching API for non-blocking operations
    • Background fetches and saves using Grand Central Dispatch
    • Automatically handle NSManagedObjectContext thread confinment
  • UI-friendly fetching with GCD

About

Simplified CoreData stack management

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published