Latest 1.4.0
License BSD
Platforms ios 8.0, osx 10.9, tvos 9.0, watchos 2.0
Frameworks CoreData

Lightweight Core Data fetch framework.

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


Example Core Data entity

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)
    .execute(in: context)

Get count

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


Aggregate minimimum value of entity property

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


Aggregate maximum value of entity property

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


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()
    .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)


  • iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 10.0+
  • Swift 4.2+



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

pod 'FetchKit'


FetchKit is released under the BSD license. See LICENSE.

Latest podspec

    "name": "FetchKit",
    "version": "1.4.0",
    "license": {
        "type": "BSD"
    "homepage": "",
    "authors": {
        "Anton Agarunov": "[email protected]"
    "summary": "Lightweight Core Data fetch framework",
    "source": {
        "git": "",
        "tag": "1.4.0"
    "module_name": "FetchKit",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "tvos": "9.0",
        "watchos": "2.0"
    "source_files": "Sources/**/*.swift",
    "frameworks": "CoreData"

Pin It on Pinterest

Share This