Lightweight Core Data fetch framework

Overview

FetchKit

Lightweight Core Data fetch framework.

With FetchKit you can easily fetch data from store without creating NSFetchRequest.

Usage

Example Core Data entity

@objc(User)
class User: NSManagedObject {
    @NSManaged var id: Int64
    @NSManaged var firstName: String?
    @NSManaged var lastName: String?
    @NSManaged var salary: Int64
}

extension User: QueryProtocol { }

Find first

Find first User. Sorted by firstName.

let user = try? User.findFirst()
    .sorted(by: \User.firstName)
    .execute(in: context)

Find all

Find all Users with first name John

let allJohns = try? User.findAll()
    .where(\User.firstName, equals: "John")
    .execute(in: context)

Find range

let ranged = try? User.findRange(2..<5)
    .sorted(by: \User.id)
    .execute(in: context)

Get count

let usersCount = try? User.getCount()
    .execute(in: context)

Min

Aggregate minimimum value of entity property

let minId = try? User.getMin(keyPath: \User.id)
    .execute(in: context)

Max

Aggregate maximum value of entity property

let maxId = try? User.getMax(keyPath: \User.id)
    .execute(in: context)

Delete

Delete all Users with first name John and returns count

let deleteCount = try? User.deleteAll()
    .where(\User.firstName, equals: "John")
    .execute(in: context)

Get Distinct

Fetch dictionaries (instead of managed objects) with specified properties and aggregation functions. Result can be grouped by properties (SQL GROUP BY)

let result = try User.getDistinct()
    .propertiesToFetch([\User.firstName])
    .aggregate(keyPath: \User.salary, function: "sum:", saveAs: "totalSalary")
    .group(by: \User.firstName)
    .execute(in: context)

Fetched results controller

Return NSFetchedResultsContoller and perform fetch

let userFetchedResults = try? User.fetchResults()
    .group(by: \User.firstName)
    .sorted(by: \User.firstName)
    .sorted(by: \User.lastName)
    .execute(in: context)

Requirements

  • iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 11.0+
  • Swift 5.1+

Installation

CocoaPods

To integrate FetchKit into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'FetchKit'

License

FetchKit is released under the BSD license. See LICENSE.

You might also like...
Passing data from a couple of screen into a Model
Passing data from a couple of screen into a Model

Passing-Data Passing data from a couple of screen into a Model Introduction Hi, this video is just a representation project from this Video by Essenti

Measure the power output from a car or any moving vehicle from GPS data and weight
Measure the power output from a car or any moving vehicle from GPS data and weight

GPSDyno Measure the power output from a car or any moving vehicle from weight and GPS data of your iOS device. This is just a example project and shou

A DSL for Data Manipulation

Underscore.m About Underscore.m Underscore.m is a small utility library to facilitate working with common data structures in Objective-C. It tries to

Easier sharing of structured data between iOS applications and share extensions
Easier sharing of structured data between iOS applications and share extensions

XExtensionItem XExtensionItem is a tiny library allowing for easier sharing of structured data between iOS applications and share extensions. It is ta

Taking a string containing a csv file and split it into records (aka lines) containing fields of data (aka Array of SubStrings)

Swift .csv parser Taking a string containing a csv file and split it into records (aka lines) containing fields of data (aka Array of SubStrings). Par

A visual developer tool for inspecting your iOS application data structures.
A visual developer tool for inspecting your iOS application data structures.

Tree Dump Debugger A visual developer tool for inspecting your iOS application data structures. Features Inspect any data structure with only one line

swift-highlight a pure-Swift data structure library designed for server applications that need to store a lot of styled text

swift-highlight is a pure-Swift data structure library designed for server applications that need to store a lot of styled text. The Highlight module is memory-efficient and uses slab allocations and small-string optimizations to pack large amounts of styled text into a small amount of memory, while still supporting efficient traversal through the Sequence protocol.

A tool to convert Apple PencilKit data to Scribble Proto3.

ScribbleConverter Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation

Data Mapping library for Objective C

OCMapper is a data mapping library for Objective C that converts NSDictionary to NSObject

Owner
Anton Agarunov
Anton Agarunov
Swift 3 framework for accessing data in Event Registry

Swift 3 framework for accessing data in Event Registry

Pavel Pantus 8 Nov 1, 2016
Butterfly is a lightweight library for integrating bug-report and feedback features with shake-motion event.

Butterfly is a lightweight library for integrating bug-report and feedback features with shake-motion event. Goals of this project One of th

Zigii Wong 410 Sep 9, 2022
GenStore is a lightweight swift code generator for your resources.

GenStore is a lightweight swift code generator for your resources. GenStore can create classes for your images, colors and localized strings.

null 11 Oct 23, 2021
Simple and Lightweight App Version Tracking for iOS written in Swift

AEAppVersion Simple and lightweight iOS App Version Tracking written in Swift I made this for personal use, but feel free to use it or contribute. For

Marko Tadić 12 Nov 11, 2022
Lightweight utilities for making OSLog more pleasant

UnifiedLoggingPlus Lightweight utilities for making OSLog more pleasant. Integration Swift Package Manager

Chime 10 Oct 26, 2022
A lightweight extension to Swift's CollectionDifference, supporting moves in addition to removals and insertions, critical when updating interfaces and managing reference types.

DifferenceTracker is a lightweight extension to Swift's CollectionDifference. It defines moves in addition to removals and insertions, critical when updating interfaces and managing reference types.

Giles Hammond 2 Nov 25, 2022
A tiny generator of random data for swift

SwiftRandom SwiftRandom is a tiny help suite for generating random data such as Random human stuff like: names, gender, titles, tags, conversations Ra

Kan Yilmaz 559 Dec 29, 2022
Functional data types and functions for any project

Swiftx Swiftx is a Swift library containing functional abstractions and extensions to the Swift Standard Library. Swiftx is a smaller and simpler way

TypeLift 219 Aug 30, 2022
A simple Pokedex app written in Swift that implements the PokeAPI, using Combine and data driven UI.

SwiftPokedex SwiftPokedex is a simple Pokedex app written by Viktor Gidlöf in Swift that implements the PokeAPI. For full documentation and implementa

Viktor G 26 Dec 14, 2022
Pigeon is a SwiftUI and UIKit library that relies on Combine to deal with asynchronous data.

Pigeon ?? Introduction Pigeon is a SwiftUI and UIKit library that relies on Combine to deal with asynchronous data. It is heavily inspired by React Qu

Fernando Martín Ortiz 369 Dec 30, 2022