Latest 2.0
License MIT
Platforms ios 10.0


Type Function Description
void push(values: <object>, keys: [String]) values are the values you want to add into your database. keys are attributes.
-> [NSManagedobject] retrieveData() Returns an array of type NSManagedObject
-> [NSManagedobject] retrieveAndSort(byKey: String, ascending: Bool) retrieves and sorts by attribute in ascending or descending order
-> [NSManagedobject] filterBy(value: <object>, withKey: String) Filter by attribute
void remove(object: [NSManagedObject], index: Int) remove an object by index.

Installation with Cocoapods

Installing SwiftyCoreData is as simple as

pod 'SwiftyCoreData'

1) Initializing

Import the CoreData module and SwiftyCoreData module

import CoreData
import SwiftyCoreData

Create an instance of the CoreDataModule class which takes 2 parameters.
entityName is the name of your created entity inside the xcDataModelID.
xcDataModelID is the name of your created Data Model file

var module = CoreDataModule(entityName: "<Entity Name>", xcDataModelID: "<Data Model Name>")

2) Save Data

Before saving data, make sure you create your entities!

Saving data, call the push() method which accepts 2 array parameters, values and keys.
values is a generic type which accepts the information you want to save.
keys are where the values are saved to and must be in the same order as the values.

mod.push(values: ["Cyril", "Garcia", 30095768], keys: ["firstname", "lastname", "id"])

3) Retrieving Data

Create an NSManagedObject array which will contain your data.

var userInfo = [NSManagedObject]()

There are 2 ways to retrieve data, either sorted or unsorted list.

To retrieve an unsorted list using the retrieveData() function which returns an [NSManagedObject]

userInfo = mod.retrieveData()

To retrieve a sorted list, use the retrieveAndSort() function
which accepts two parameters, byKey: String and ascending: Bool
byKey determins what to sort and ascending determins if you want to sort in ascending order or not.

userInfo = mod.retrieveAndSort(byKey: "id", ascending: true)

To filter data, use the filterBy() function which accepts two parameters, value: <object> and withKey: String

userInfo = mod.filterBy(value: "30097568", withKey: "id")

4) Delete Data

To delete, call the remove() function which accepts 2 parameters, object:[NSManagedObject] and index:Int

mod.remove(object: userInfo, index: <Index of the data you want to delete>)

SwiftyCoreData • Developed By Cyril

Latest podspec

    "name": "SwiftyCoreData",
    "version": "2.0",
    "summary": "Making CoreData easier to implement",
    "description": "An easy way to implement CoreData in your iOS applications",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Cyril Garcia": "[email protected]"
    "source": {
        "git": "",
        "tag": "2.0"
    "platforms": {
        "ios": "10.0"
    "source_files": "EasyCoreData/*.swift",
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This