struct KeyPathComparator<Compared> : SortComparator
<aside> π‘ λ€λ₯Έ μ λ ¬ μκ³ λ¦¬μ¦μ keypathμ κ°μ μ λ¬νμ¬ λΉκ΅νλ μ λ ¬ μκ³ λ¦¬μ¦.
</aside>
KeyPathComparator
λ μ λ ¬ μκ³ λ¦¬μ¦μ μμ± λ° μ λ¬νλ μ¬μ΄ λ°©λ²μ μ 곡νλ€. λΉκ΅ν νμ
μμ λΉκ΅ λμ νλ‘νΌν°λ₯Ό KeyPathλ‘ λͺ
μνκ³ , λ€λ₯Έ Comparator
μ ν΄λΉ νλ‘νΌν°μ λΉκ΅ λμμ μμνλ€. μμ±μμμ comparator
μΈμλ₯Ό λͺ
μνμ§ μμ κ²½μ° κΈ°λ³Έμ μΌλ‘ ComparableComparator
λ₯Ό μ λ ¬ μκ³ λ¦¬μ¦μΌλ‘ μ¬μ©νλ€.
SortDescriptor
μμ κ°μ₯ ν° μ°¨μ΄μ μ μ λ ¬ λμ κ°μ²΄κ° Obj-C λ°νμμ λ
ΈμΆλ νμκ° μλ€λ κ²μ΄λ€. μ¦ κ°μ²΄κ° NSObject
λ₯Ό μμλ°μμΌ νλ€κ±°λ νλ‘νΌν°μ @objc
νΉμ±μ λΆμ¬μΌνλ μ μ½μ΄ μλ€.
SortComparator
μ μ¬μ©μ²μμ μ¬μ©λλ€.
init<Value>(_ keyPath: KeyPath<Compared, Value>, order: SortOrder = .forward) where Value : Comparable
init<Value>(_ keyPath: KeyPath<Compared, Value?>, order: SortOrder = .forward) where Value : Comparable
init<Value, Comparator>(_ keyPath: KeyPath<Compared, Value>, comparator: Comparator) where Value == Comparator.Compared, Comparator : SortComparator
init<Value, Comparator>(_ keyPath: KeyPath<Compared, Value?>, comparator: Comparator) where Value == Comparator.Compared, Comparator : SortComparator
init<Value, Comparator>(_ keyPath: KeyPath<Compared, Value>, comparator: Comparator, order: SortOrder) where Value == Comparator.Compared, Comparator : SortComparator
init<Value, Comparator>(_ keyPath: KeyPath<Compared, Value?>, comparator: Comparator, order: SortOrder) where Value == Comparator.Compared, Comparator : SortComparator
// conforming SortComparator
compare(_ lhs: Compared, _ rhs: Compared) -> ComparisonResult
var order: SortOrder
**let keyPath: PartialKeyPath<Compared>**
// SortComparator inherits Hashable
func hash(into hasher: inout Hasher)
var hashValue: Int
// Hashable inherits Equatable
static func == (lhs: KeyPathComparator<Compared>, rhs: KeyPathComparator<Compared>) -> Bool
static func != (lhs: KeyPathComparator<Compared>, rhs: KeyPathComparator<Compared>) -> Bool