diff --git a/SwiftForms/controllers/FormOptionsViewController.swift b/SwiftForms/controllers/FormOptionsViewController.swift index 1146359..0e2d1b3 100644 --- a/SwiftForms/controllers/FormOptionsViewController.swift +++ b/SwiftForms/controllers/FormOptionsViewController.swift @@ -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 @@ -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 { diff --git a/SwiftFormsApplication/ExampleFormViewController.swift b/SwiftFormsApplication/ExampleFormViewController.swift index 4bcd5ea..2e341ac 100644 --- a/SwiftFormsApplication/ExampleFormViewController.swift +++ b/SwiftFormsApplication/ExampleFormViewController.swift @@ -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 "" }