added utilities for combining Where arrays and OrderBy arrays

This commit is contained in:
John Rommel Estropia
2017-06-24 17:42:56 +09:00
parent e8eb309d82
commit f72efc80b2
2 changed files with 36 additions and 0 deletions

View File

@@ -172,3 +172,17 @@ public struct OrderBy: FetchClause, QueryClause, DeleteClause, Hashable {
return (self.sortDescriptors as NSArray).hashValue
}
}
// MARK: - Sequence where Element == OrderBy
public extension Sequence where Iterator.Element == OrderBy {
/**
Combines multiple `OrderBy` predicates together
*/
public func combined() -> OrderBy {
return OrderBy(self.flatMap({ $0.sortDescriptors }))
}
}