TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Oliver Staats.
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.
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.
pod 'KORData'
Theres an example project included, KORDataExampleIOS.