Skip to content

rpanchal/Vokoder

 
 

Repository files navigation

Vokoder

CI Status Version License Platform

A lightweight core data stack with efficient importing and exporting on the side.

Installation

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

pod "Vokoder"

Subspecs

The bulk of the functionality is in the Core subspec. If you aren't using any of the data sources, you can just include the Core subspec.

Data sources to facilitate backing various kinds of views with data from Core Data are in the DataSources subspec, which is further broken down into:

  • FetchedResults contains a basic data source based on a fetched results controller, intended to be used with a UITableView.
  • PagingFetchedResults is based on FetchedResults but supports paged loading.
  • Collection is based on FetchedResults, but intended for use with a UICollectionView.
  • Carousel (not included by default) is based on FetchedResults but intended for use with iCarousel (and hence includes it as a dependency).

##Usage

###Setting up the data model

[[VOKCoreDataManager sharedInstance] setResource:@"VICoreDataModel" database:@"VICoreDataModel.sqlite"]; //Saved to Disk

Or

[[VOKCoreDataManager sharedInstance] setResource:@"VICoreDataModel" database:nil]; //In memory data store

###Inserting records

VIPerson *person = [VIPerson vok_newInstance];
[person setFirstName:@"Rohan"];
[person setLastName:@"Panchal"];
[[VOKCoreDataManager sharedInstance] saveMainContextAndWait];

###Querying Records

####Query with basic predicate

NSArray *results = [VIPerson vok_fetchAllForPredicate:nil forManagedObjectContext:nil]; //Basic Fetch

####Query with basic predicate and sorting

NSArray *results = [VIPerson vok_fetchAllForPredicate:nil
                                          sortedByKey:@"numberOfCats"
                                            ascending:YES
                              forManagedObjectContext:nil];

###Deleting records

VOKCoreDataManager *manager = [VOKCoreDataManager sharedInstance];
[manager deleteObject:person];
[[VOKCoreDataManager sharedInstance] saveMainContextAndWait];

###Saving

[[VOKCoreDataManager sharedInstance] saveMainContextAndWait]; //Saves synchronously

####Saving on background thread

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
    NSManagedObjectContext *backgroundContext = [[VOKCoreDataManager sharedInstance] temporaryContext];
        
    VIPerson *person = [VIThing vok_newInstanceWithContext:backgroundContext];
	[person setNumberOfCats:@1];
    [[VOKCoreDataManager sharedInstance] saveAndMergeWithMainContext:backgroundContext];
});

License

Vokoder is available under the MIT license. See the LICENSE file for more info.

About

A lightweight core data stack with efficient importing and exporting on the side.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 83.4%
  • XML 6.0%
  • Shell 4.9%
  • C 2.7%
  • Ruby 2.5%
  • C++ 0.5%