Giter Club home page Giter Club logo

jbcoredataagent's Introduction

JBCoreDataAgent

CoreDataAgent - Helps wrangle all core data methods into one tidy little package. Makes adding core data to an existing project very simple. Creates NSFetchRequests and NSFetchedResultsControllers, quickly and easily

To install

Cocoapods Visit cocoapods.org for installation instructions

Add this to your Podfile.

pod 'JBCoreDataAgent', git: "https://github.com/jbueler/JBCoreDataAgent", tag: '0.0.3'

Without cocoapods Download the .h & .m files. Add them to your project. Make sure you add the CoreData framework if you don't already have it in the project. You will also need a datamodel file, where your entities are setup.

To Do:

  • Add NSFetchRequest & NSFetchedResultsController management (create the ability to store multiple FRCs & FRs) within the CoreDataAgent.

Implementation

======== Once JBCoreDataAgent is included into the project and you have a DataModel.xcdatamodeld file with your entities described in it. You can import JBCoreDataAgent.h

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // Allocate and initialize the CoreDataObject 
  JBCoreDataAgent *coreDataAgent = [[JBCoreDataAgent alloc] initWithStoreName:@"<#DataModel#>" andDelegate: <#NSFetchedResultsControllerDelegate#>];
  
  //Create a NSFetchRequest
  NSFetchRequest *fetchRequest = [coreDataAgent fetchRequest:@"<#EntityName#>" andSort:@"<#entity_attribute_to_sort_by#>" ascending:<#true#>];
  
  // Once you have the fetchRequest you can either perform the fetch with it, or create a NSFetchedResultsController and perform the fetch that way.
  //Perform fetch with fetchRequest
  // NSArray *resultsArray = [coreDataAgent performFetchWithFetchRequest: fetchRequest];
  
  // OR       
  // Perform fetch with NSFetchedResultsController (Good when dealing with UITableViews)
  NSFetchedResultsController *frc = [coreDataAgent fetchedResultsControllerWithFetchRequest: fetchRequest];
  [coreDataAgent performFetchWithFetchResultsController: frc];

  // DO WHATEVER YOU WANT ... 

  return YES;
}

Credit to:

Dru Kepple for kicking ass and coming up with this idea. https://github.com/drukepple

jbcoredataagent's People

Contributors

jbueler avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.