Skip to content
A type-safe Realm query extensions using Swift 4 Smart KeyPaths
Swift Ruby Objective-C Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Carthage/Checkouts
Configurations
RealmTypeSafeQuery.xcodeproj
RealmTypeSafeQuery.xcworkspace
RealmTypeSafeQuery
RealmTypeSafeQueryTests
Scripts
bin
.gitignore
.gitmodules
.swift-version
.travis.yml
CHANGELOG.md
Cartfile
Cartfile.resolved
LICENSE
README.md
RealmTypeSafeQuery.podspec

README.md

RealmTypeSafeQuery

Build Status Codecov Pods Version Platforms Carthage Compatible Swift 4.0 Swift 4.1 Swift 4.2

A type-safe Realm query extensions using Swift 4's Smart KeyPaths.

Requirements

RealmTypeSafeQuery is written in Swift 4.

Installation

CocoaPods

RealmTypeSafeQuery is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'RealmTypeSafeQuery'

Carthage

For Carthage, add the following to your Cartfile:

github "kishikawakatsumi/RealmTypeSafeQuery"

Description

RealmTypeSafeQuery provides type safety, code completion and avoidance of typos against NSPredicate queries.

Before

realm.objects(Person.self).filter("name == %@", "Katsumi")
realm.objects(Person.self).filter("age > %@", 20)

After

realm.objects(Person.self).filter(\Person.name == "Katsumi")
realm.objects(Person.self).filter(\Person.age > 20)

The following code should be a compile error.

realm.objects(Person.self).filter(\Person.name > 20) // Compile error
realm.objects(Person.self).filter(\Dog.name == "John") // Compile error

Feature request for Swift Standard Library

It requires a string representation of KeyPath to construct NSPredicate from KeyPath. However, the API is not officially visible currently. The feature request is tracked at SR-5220.

[SR-5220] Expose API to retrieve string representation of KeyPath - Swift

You can’t perform that action at this time.