Giter Site home page Giter Site logo

aucoredatakit's Introduction

Language CocoaPods compatible Carthage compatible Build Status

DataKit

An easy to use CoreData wrapper in Swift.

Requirements

DataKit requires Swift 5.0 and Xcode 10.2.

Installation

CocoaPods

You can use CocoaPods to integrate DataKit with your project.

Simply add the following line to your Podfile:

pod "AUCoreDataKit"

And run pod update in your project directory.

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate NetKit into your Xcode project using Carthage, specify it in your Cartfile:

github "azizuysal/AUCoreDataKit"

Run carthage update to build the framework and drag the built DataKit.framework into your Xcode project.

Manually

You can integrate DataKit manually into your project simply by dragging DataKit.framework onto Linked Frameworks and Libraries section in Xcode.

Usage

Optionally configure DataKit if the defaults are not suitable for your use case. DataKit automatically merges and uses CoreData models created in Xcode and uses Application name to name its database file:

DataKit.configure({
    var config = DataKit.Configuration()
    config.dbUrl = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first!.appendingPathComponent("test.db")
    return config
})

You must call this method once to load data stores for CoreData. You can start using DataKit as soon as the data stores are loaded in the callback. If there was an error, the error parameter will contain the details.

DataKit.loadStores { error in
  // your code here
}

Afterwards, you can start using convenient methods on your model classes to interact with core data store:

var story = Story.new()
story.title = "DataKit IS Great!"
story.save()

Or use JsonLoadable protocol to load data from a web api:

Story.execute(in: DataKit.newPrivateContext()) { context in
    print("Saving story \(id)")
    Story.insertOrUpdateOne(storyJson, in: context, idKey: "id", idColumn: "storyId", idType: Int32.self)
}

Refer to the example project for more usage examples.

Please email me if you'd like more examples and/or additional features.

##License

The MIT License (MIT)

aucoredatakit's People

Contributors

azizuysal avatar

Stargazers

Carabineiro avatar

Watchers

James Cloos avatar  avatar Carabineiro avatar

Forkers

carabina

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.