All Projects → Krivoblotsky → Hardcoredata

Krivoblotsky / Hardcoredata

Licence: mit
CoreData stack and controller that will never block UI thread

Projects that are alternatives of or similar to Hardcoredata

Tothepenny
A budget tracker app for iOS
Stars: ✭ 82 (-60.39%)
Mutual labels:  coredata
Swiftui Core Data Test
Sample program to demonstrate how CoreData can be used with SwiftUI.
Stars: ✭ 135 (-34.78%)
Mutual labels:  coredata
Clean Architecture Swiftui
SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.
Stars: ✭ 2,925 (+1313.04%)
Mutual labels:  coredata
Hardchoice
有时候作抉择真的很痛苦,Swift写的生活类APP
Stars: ✭ 90 (-56.52%)
Mutual labels:  coredata
Dictionaryplusplus
Dictionary++ is a simple interface to iOS's system dictionary.
Stars: ✭ 112 (-45.89%)
Mutual labels:  coredata
Cloudcore
Framework that enables syncing between iCloud (CloudKit) and Core Data
Stars: ✭ 146 (-29.47%)
Mutual labels:  coredata
Ios Sdk
AppSpector is a debugging service for mobile apps
Stars: ✭ 56 (-72.95%)
Mutual labels:  coredata
Core Data Editor
Core Data Editor lets you easily view, edit and analyze applications‘ data. Core Data Editor is compatible with Mac and iOS applications and supports XML, SQLite and binary stores, visualizes all relationships and is able to edit the data and generate Objective-C code for the data model.
Stars: ✭ 2,106 (+917.39%)
Mutual labels:  coredata
Widgetexamples
A demo project showcasing different types of Widgets created with SwiftUI and WidgetKit.
Stars: ✭ 125 (-39.61%)
Mutual labels:  coredata
Upcomingmovies
Movies app written in Swift 5 using the TMDb API and demonstrating Clean Architecture, Dependency Injection, MVVM and Coordinators.
Stars: ✭ 160 (-22.71%)
Mutual labels:  coredata
Bgfmdb
BGFMDB让数据的增删改查分别只需要一行代码即可,就是这么简单任性,本库几乎支持存储ios所有基本的自带数据类型.
Stars: ✭ 1,344 (+549.28%)
Mutual labels:  coredata
Predicateflow
Write amazing, strong-typed and easy-to-read NSPredicate.
Stars: ✭ 98 (-52.66%)
Mutual labels:  coredata
Justpersist
JustPersist is the easiest and safest way to do persistence on iOS with Core Data support out of the box. It also allows you to migrate to any other persistence framework with minimal effort.
Stars: ✭ 157 (-24.15%)
Mutual labels:  coredata
Shob
SwiftUI + CoreData & iCloud AutoSync Project
Stars: ✭ 90 (-56.52%)
Mutual labels:  coredata
Velik
Ride tracking app
Stars: ✭ 168 (-18.84%)
Mutual labels:  coredata
Jotify
Sticky notes reimagined - written in Swift
Stars: ✭ 79 (-61.84%)
Mutual labels:  coredata
Coredataplaygrounds
Exploring Core Data through Swift playgrounds
Stars: ✭ 139 (-32.85%)
Mutual labels:  coredata
Swiftdb
A modern database abstraction layer, batteries included.
Stars: ✭ 183 (-11.59%)
Mutual labels:  coredata
Coredatabestpractices
Best Practices in Core Data explained within a demo application
Stars: ✭ 171 (-17.39%)
Mutual labels:  coredata
Coredata Crud Swift 5.0 Example
Swift 5.0 Example project that exposes the usage of Core Data to create Entities and to persist to a SQLite Datastore
Stars: ✭ 157 (-24.15%)
Mutual labels:  coredata

HardCoreData Build Status Version Platform

teaser

HardCoreData is a yet another core data stack based on Marcus Zarra's multithreading approach. This smart approach uncouples the writing into its own private queue and keeps the UI smooth as button.

teaser

HardCoreData consists of two fundamentals: HCDCoreDataStack and HCDCoreDataStackController.

HCDCoreDataStack

Incapsulates native CoreData stack setup.

/* Convenience initializers */

+ (instancetype)binaryStackWithName:(NSString *)modelName;
+ (instancetype)inMemoryStackWithName:(NSString *)modelName;
+ (instancetype)sqliteStackWithName:(NSString *)modelName;
+ (instancetype)stackWithModelName:(NSString *)modelName storeType:(NSString *)storeType;

/**
 *  Designated initializer
 *
 *  @param modelName NSString
 *  @param storeType NSString
 *
 *  @return HCDCoreDataStack
 */

- (instancetype)initWithModelName:(NSString *)modelName storeType:(NSString *)storeType NS_DESIGNATED_INITIALIZER;

HCDCoreDataStack protocol

Since HCDCoreDataStack is a protocol as well as a class, you can create your own custom stacks, by implementing protocol.

@protocol HCDCoreDataStack <NSObject>

@required

/* Represents current store coordinator */
@property (nonatomic, strong, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;

/* Represents currentm object model */
@property (nonatomic, strong, readonly) NSManagedObjectModel *managedObjectModel;

/* Represents your single source of truth. Associated with main queue. */
@property (nonatomic, strong, readonly) NSManagedObjectContext *mainManagedObjectContext;

@end

HCDCoreDataStackController

The controller to instantiate child MOCs and save the while chain to the persistent store.

/**
 *  Designated initializer
 *
 *  @param stack HCDCoreDataStack
 *
 *  @return HCDCoreDataStackController
 */
- (instancetype)initWithStack:(id <HCDCoreDataStack>)stack NS_DESIGNATED_INITIALIZER;

/**
 * Instantiates new child context with given concurrency type.
 * You are responsive for retaining.
 */
- (NSManagedObjectContext *)createChildContextWithType:(NSManagedObjectContextConcurrencyType)type;

/**
 *  Saves the main context and pushes changes to the store.
 *  Its thread-safe to call it.
 */
- (void)save;

The whole pattern

/* Create core data stack */
HCDCoreDataStack *stack = [HCDCoreDataStack sqliteStackWithName:@"Model"];
HCDCoreDataStackController *coreDataController = [HCDCoreDataStackController controllerWithStack:stack];

NSManagedObjectContext *backgroundContext = [coreDataController createChildContextWithType:NSPrivateQueueConcurrencyType];
  [backgroundContext performBlock:^{
   
    Person *person = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([Person class]) inManagedObjectContext:backgroundContext];
    person.firstName = @"John";
    person.lastName = @"Doe";
    
    /* Save child context */
    [backgroundContext save:nil];
    
    /* Save data to store */
    [coreDataController save];
}];

Checkout Example folder for complete example.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

HardCoreData is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "HardCoreData"

Author

Serg Krivoblotsky, [email protected]

History

See Releases

License

HardCoreData is available under the MIT license.

Copyright (c) 2015 Serg Krivoblotsky <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].