Add filteredWith IN and NOT IN (#305)

* fiteredWith IN and NOT IN added

* Update Request.swift
This commit is contained in:
Michal Kolesar 2016-10-13 09:12:42 +02:00 committed by Pedro Piñera Buendía
parent b57b57be29
commit 037260e81f

View File

@ -45,6 +45,17 @@ public struct FetchRequest<T: Entity>: Equatable {
.request(withPredicate: NSPredicate(format: "\(key) == %@", value))
}
public func filtered(with key: String, in value: [String]) -> FetchRequest<T> {
return self
.request(withPredicate: NSPredicate(format: "\(key) IN %@", value))
}
public func filtered(with key: String, notIn value: [String]) -> FetchRequest<T> {
return self
.request(withPredicate: NSPredicate(format: "NOT (\(key) IN %@)", value))
}
public func sorted(with sortDescriptor: NSSortDescriptor) -> FetchRequest<T> {
return self
.request(withSortDescriptor: sortDescriptor)