Latest | 0.1.2 |
---|---|
Homepage | https://github.com/olistaats/KORData |
License | MIT |
Platforms | ios 7.0, requires ARC |
Frameworks | CoreData |
Authors |
About
KORData lets you create a project that initializes Core Data and simplifies the use of NSFetchedResultsController . The result is that you can create a NSFetchedResultsController in a couple of lines of code, with or without subclassing.
Example
In the following example, AnimalController is a ViewController that has an embedded KORDataTableViewController, as provided by the framework.
The KORDataTableViewController, is configured in the prepare for segue, without subclassing. The whole ViewController
with the embedded KORDataTableViewController is shown below.
@implementation AnimalController
// lightweight dependency injection methodology
- (void)postInitSetup:(ConfiguratorInjector *)inj farm:(Farm *)farm {
_animalFarmService = inj.animalFarmService;
_farm = farm;
}
// An embeded KORDataTableViewController is in the storyboard. Just inject a little behavior
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.destinationViewController isKindOfClass:[KORDataTableViewController class]]) {
KORDataTableViewController *kor = segue.destinationViewController;
[kor postInitSetupWithContext:self.animalFarmService.managedObjectContext
selectRowBlock:nil
cellIdentifier:@"AnimalFarmCell"
cellForRowBlock:^(Animal *animal, UITableViewCell *cell, NSIndexPath *indexPath) {
cell.textLabel.text = animal.name;
}];
kor.fetchRequest = [[self.animalFarmService animalsForFarm:self.farm] fetchRequest];
}
}
@end
NOTE: The example uses a service class rather than category on the "Animal" managed object subclass. This is deliberately not an active record pattern, which is not the only way to simplify core data.
The example also uses the KEYShadow type safe query framework, within the animalFarmService. While this simplifies the code, it is optional.
How to get it (PODS)
pod ‘KORData’
Example Project
Theres an example project included, KORDataExampleIOS.
Latest podspec
{ "name": "KORData", "version": "0.1.2", "license": { "type": "MIT", "file": "LICENSE" }, "homepage": "https://github.com/olistaats/KORData", "authors": { "olistaats": "[email protected]" }, "source": { "git": "https://github.com/olistaats/KORData.git", "tag": "0.1.2" }, "requires_arc": true, "summary": "Simplified Core Data and NSFetchedResultsController", "description": "Simplified Core Data setup and NSFetchedResultsController use. Reduce controller code to a couple of lines, with or without subclassing", "platforms": { "ios": "7.0" }, "public_header_files": "KORData/*.h", "frameworks": "CoreData", "source_files": "KORData/*.{m,h}" }
Mon, 29 Feb 2016 00:35:03 +0000