Giter Site home page Giter Site logo

records's Introduction

Records

Build Carthage codebeat badge Twitter: @nashytitz

A very light-weight CoreData wrapper that dynamically re-writes itself, as you develop your project.

CoreData

Fetch

do {
  let performances: [Performance] = try Performance.Query(group: .solo).all(in: context)
  performances.forEach { (performance) in
    context.delete(performance)
  }
  try context.save()
} catch {
  // Errors from the CoreData layer such as 'model not found' etc
}

More details

Create

struct Information {
    let name: String
    let phone: String
    let email: String
    let type: String

    // implement protocol named `Recordable` here ~ 2 minutes
}

let info = Information(name: "DanceSchool", phone: "01234567891", email: "[email protected]", type: "School")

do {
    let record: Party = try info.record(in: context)
} catch {
    // Errors from the CoreData layer such as 'model not found' etc
}

When using the protocol named Recordable we ensure the following is performed when we call record(in: ).

  1. If a record does not exist that matches this data, it is created.
  2. If a record does exist that matches this data, it is retrieved.

More details

Observe

The following tableView is connected to an NSFetchedResultsController and UI changes are delegated to a default protocol implementation.

class PerformancesViewController: UIViewController {
  
  private let fetchedResultsController: PerformancesFetchedResultsController!
  
  @IBOutlet private weak var tableView: PerformancesTableView! {
    didSet {
      fetchedResultsController.delegate = tableView
      fetchedResultsController.dataSource = tableView
      tableView.dataSource = fetchedResultsController
      tableView.delegate = fetchedResultsController
    }
  }
  
  override func viewDidLoad() {
    super.viewDidLoad()
    try! fetchedResultsController.reload()
  } 
}

More details

Installation

  1. Run the Carthage command carthage update.
  2. Embed Binary.
  3. Install Sourcery.
  4. Adjust NSManagedObject subclasses ~2 minute job.

See Guide

Demo

  1. Run the Carthage command carthage bootstrap.
  2. Install Sourcery.
  3. Run the Xcode scheme named Performances.

Footnotes

See footnotes for some handy tips.

records's People

Contributors

fossabot avatar nashysolutions avatar

Watchers

 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.