Latest 2.0.0
License MIT
Platforms ios 9.0
Frameworks CoreData


Build Status
CocoaPods Compatible
Coverage Status

DataManager is a lightweight Core Data utility. It is not a replacement/wrapper for Core Data. Here are some of the highlights:

  • Encapsulates the boilerplate associated with setting up the Core Data stack.
  • Sets up the stack with a private NSPrivateQueueConcurrencyType context as the root context with a public NSMainQueueConcurrencyType child context. This setup allows for asynchronous saves to disk.
  • Provides Swift-friendly convenience fetching methods that make use of generics to prevent you from having to handle downcasting from NSManagedObject to the entity’s class every time you perform a fetch.


  • iOS 9.0
  • Swift 4.2


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

pod 'DataManager'

If you would like to test a beta version of DataManager, you can install the latest from develop:

pod 'DataManager', :git => '', :branch => 'develop'



When your app is launched, set up DataManager with the data model name and a name for the persistent store file:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    DataManager.setUp(withDataModelName: "MyApp", bundle: .main, persistentStoreName: "MyApp")

    /* ... */

    return true

This won’t set up the Core Data stack right away. The stack is lazy loaded when DataManager.mainContext is first used.


DataManager uses generics so you don’t have to worry about casting the NSManagedObject results to the entity’s class every time you perform a fetch. For example, the type of olderUsers below is [User].

let predicate = NSPredicate(format: "(#keyPath(Person.birthDate)) < %@", someDate)
let olderUsers = DataManager.fetchObjects(entity: User.self, predicate: predicate, context: DataManager.mainContext)


DataManager.delete([user1, user2], in: DataManager.mainContext)


DataManager.persist(synchronously: false)

Child Contexts

let backgroundContext = DataManager.createChildContext(withParent: DataManager.mainContext)

backgroundContext.perform {
    /* Do heavy lifting in the background */


DataManager is owned and maintained by Metova Inc.



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


Latest podspec

    "name": "DataManager",
    "version": "2.0.0",
    "summary": "DataManager is a small utility class that helps you manage Core Data.",
    "description": "DataManager takes care of Core Data boilerplate code for you. It handles setting up the Core Data stack with support for asynchronous saves. It also includes a few simple fetch and deletion methods.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Logan Gauthier": "[email protected]"
    "platforms": {
        "ios": "9.0"
    "swift_version": "4.2",
    "source": {
        "git": "",
        "tag": "2.0.0"
    "source_files": "Sources/*.swift",
    "frameworks": "CoreData"

Pin It on Pinterest

Share This