Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SegmentedCell: cast row to OptionsRow not to the SegmentedRow #2183

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/Rows/SegmentedRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ open class SegmentedCell<T: Equatable> : Cell<T>, CellType {
}

@objc (valueDidChange) func valueChanged() {
row.value = (row as! SegmentedRow<T>).options?[segmentedControl.selectedSegmentIndex]
row.value = (row as! OptionsRow<Self>).options?[segmentedControl.selectedSegmentIndex]
}

open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
Expand All @@ -131,7 +131,7 @@ open class SegmentedCell<T: Equatable> : Cell<T>, CellType {
func updateSegmentedControl() {
segmentedControl.removeAllSegments()

(row as! SegmentedRow<T>).options?.reversed().forEach {
(row as! OptionsRow<Self>).options?.reversed().forEach {
if let image = $0 as? UIImage {
segmentedControl.insertSegment(with: image, at: 0, animated: false)
} else {
Expand Down Expand Up @@ -180,7 +180,7 @@ open class SegmentedCell<T: Equatable> : Cell<T>, CellType {

func selectedIndex() -> Int? {
guard let value = row.value else { return nil }
return (row as! SegmentedRow<T>).options?.firstIndex(of: value)
return (row as! OptionsRow<Self>).options?.firstIndex(of: value)
}
}

Expand Down