Skip to content
This repository was archived by the owner on Apr 19, 2021. It is now read-only.
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions SwiftForms/controllers/FormOptionsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ open class FormOptionsSelectorController: UITableViewController, FormSelector {
cell?.textLabel?.text = formCell?.rowDescriptor?.configuration.selection.optionTitleClosure?(optionValue)

if let selectedOptions = formCell?.rowDescriptor?.value as? [AnyObject] {
if let _ = selectedOptions.index(where: { $0 === optionValue }) {
if let _ = selectedOptions.index(where: { $0 as! AnyHashable == optionValue as! AnyHashable }) {
cell?.accessoryType = .checkmark
} else {
cell?.accessoryType = .none
Expand Down Expand Up @@ -96,7 +96,7 @@ open class FormOptionsSelectorController: UITableViewController, FormSelector {

if allowsMultipleSelection {
if var selectedOptions = formCell?.rowDescriptor?.value as? [AnyObject] {
if let index = selectedOptions.index(where: { $0 === selectedOption }) {
if let index = selectedOptions.index(where: { $0 as! AnyHashable == selectedOption as! AnyHashable }) {
selectedOptions.remove(at: index)
cell?.accessoryType = .none
} else {
Expand Down
1 change: 1 addition & 0 deletions SwiftFormsApplication/ExampleFormViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class ExampleFormViewController: FormViewController {

row = FormRowDescriptor(tag: Static.categories, type: .multipleSelector, title: "Categories")
row.configuration.selection.options = ([0, 1, 2, 3, 4] as [Int]) as [AnyObject]
row.value = [1,4] as AnyObject?
row.configuration.selection.allowsMultipleSelection = true
row.configuration.selection.optionTitleClosure = { value in
guard let option = value as? Int else { return "" }
Expand Down