{"id":13428709,"url":"https://github.com/Krivoblotsky/HardCoreData","last_synced_at":"2025-03-16T01:32:58.418Z","repository":{"id":31666188,"uuid":"35231628","full_name":"Krivoblotsky/HardCoreData","owner":"Krivoblotsky","description":"CoreData stack and controller that will never block UI thread","archived":false,"fork":false,"pushed_at":"2015-06-17T14:50:02.000Z","size":343,"stargazers_count":208,"open_issues_count":0,"forks_count":18,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-05T12:51:50.837Z","etag":null,"topics":["coredata","ios","macos","objective-c"],"latest_commit_sha":null,"homepage":"https://github.com/Krivoblotsky/HardCoreData","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Krivoblotsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-07T16:41:45.000Z","updated_at":"2024-06-07T09:10:42.000Z","dependencies_parsed_at":"2022-09-10T07:02:00.171Z","dependency_job_id":null,"html_url":"https://github.com/Krivoblotsky/HardCoreData","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivoblotsky%2FHardCoreData","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivoblotsky%2FHardCoreData/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivoblotsky%2FHardCoreData/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Krivoblotsky%2FHardCoreData/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Krivoblotsky","download_url":"https://codeload.github.com/Krivoblotsky/HardCoreData/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814905,"owners_count":20352037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coredata","ios","macos","objective-c"],"created_at":"2024-07-31T01:01:03.274Z","updated_at":"2025-03-16T01:32:58.095Z","avatar_url":"https://github.com/Krivoblotsky.png","language":"Objective-C","readme":"# HardCoreData [![Build Status](https://travis-ci.org/Krivoblotsky/HardCoreData.svg?branch=master)](https://travis-ci.org/Krivoblotsky/HardCoreData) [![Version](https://img.shields.io/badge/version-0.1.1-cacaca.svg)](https://github.com/Krivoblotsky/HardCoreData) [![Platform](https://img.shields.io/badge/platform-ios|osx-blue.svg)](https://github.com/Krivoblotsky/HardCoreData)\n\n![teaser](/screenshots/teaser_v2.png)\n\nHardCoreData is a yet another core data stack based on Marcus Zarra's multithreading [approach](http://www.cocoanetics.com/2012/07/multi-context-coredata/). This smart approach uncouples the writing into its own private queue and keeps the UI smooth as button.\n\n![teaser](/screenshots/stack_dia.png)\n\nHardCoreData consists of two fundamentals: HCDCoreDataStack and HCDCoreDataStackController.\n\n#### HCDCoreDataStack\n\nIncapsulates native CoreData stack setup.\n\n```objc\n\n/* Convenience initializers */\n\n+ (instancetype)binaryStackWithName:(NSString *)modelName;\n+ (instancetype)inMemoryStackWithName:(NSString *)modelName;\n+ (instancetype)sqliteStackWithName:(NSString *)modelName;\n+ (instancetype)stackWithModelName:(NSString *)modelName storeType:(NSString *)storeType;\n\n/**\n *  Designated initializer\n *\n *  @param modelName NSString\n *  @param storeType NSString\n *\n *  @return HCDCoreDataStack\n */\n\n- (instancetype)initWithModelName:(NSString *)modelName storeType:(NSString *)storeType NS_DESIGNATED_INITIALIZER;\n```\n\n#### HCDCoreDataStack protocol\n\nSince HCDCoreDataStack is a protocol as well as a class, you can create your own custom stacks, by implementing \u003cHCDCoreDataStack\u003e protocol.\n\n```objc\n\n@protocol HCDCoreDataStack \u003cNSObject\u003e\n\n@required\n\n/* Represents current store coordinator */\n@property (nonatomic, strong, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;\n\n/* Represents currentm object model */\n@property (nonatomic, strong, readonly) NSManagedObjectModel *managedObjectModel;\n\n/* Represents your single source of truth. Associated with main queue. */\n@property (nonatomic, strong, readonly) NSManagedObjectContext *mainManagedObjectContext;\n\n@end\n\n```\n\n#### HCDCoreDataStackController\n\nThe controller to instantiate child MOCs and save the while chain to the persistent store.\n\n```objc\n\n/**\n *  Designated initializer\n *\n *  @param stack HCDCoreDataStack\n *\n *  @return HCDCoreDataStackController\n */\n- (instancetype)initWithStack:(id \u003cHCDCoreDataStack\u003e)stack NS_DESIGNATED_INITIALIZER;\n\n/**\n * Instantiates new child context with given concurrency type.\n * You are responsive for retaining.\n */\n- (NSManagedObjectContext *)createChildContextWithType:(NSManagedObjectContextConcurrencyType)type;\n\n/**\n *  Saves the main context and pushes changes to the store.\n *  Its thread-safe to call it.\n */\n- (void)save;\n\n```\n\n\n### The whole pattern\n\n```objc\n\n/* Create core data stack */\nHCDCoreDataStack *stack = [HCDCoreDataStack sqliteStackWithName:@\"Model\"];\nHCDCoreDataStackController *coreDataController = [HCDCoreDataStackController controllerWithStack:stack];\n\nNSManagedObjectContext *backgroundContext = [coreDataController createChildContextWithType:NSPrivateQueueConcurrencyType];\n  [backgroundContext performBlock:^{\n   \n    Person *person = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([Person class]) inManagedObjectContext:backgroundContext];\n    person.firstName = @\"John\";\n    person.lastName = @\"Doe\";\n    \n    /* Save child context */\n    [backgroundContext save:nil];\n    \n    /* Save data to store */\n    [coreDataController save];\n}];\n\n```\n\nCheckout [Example](https://github.com/Krivoblotsky/HardCoreData/tree/master/Example) folder for complete example.\n\n## Usage\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Installation\n\nHardCoreData is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"HardCoreData\"\n```\n\n## Author\n\nSerg Krivoblotsky, krivoblotsky@me.com\n\n## History\n\nSee [Releases](https://github.com/Krivoblotsky/HardCoreData/releases)\n\n## License\n\nHardCoreData is available under the MIT license.\n\n```\nCopyright (c) 2015 Serg Krivoblotsky \u003ckrivoblotsky@me.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n","funding_links":[],"categories":["Core Data"],"sub_categories":["Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKrivoblotsky%2FHardCoreData","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKrivoblotsky%2FHardCoreData","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKrivoblotsky%2FHardCoreData/lists"}