Reputation: 4349
I have this code for Eureka
library:
let section = SelectableSection<ImageCheckRow<String>, String>("Section:", selectionType: .MultipleSelection)
section.tag = "section"
for obj in arrList {
section <<< ImageCheckRow<String>(obj.name){ row in
row.title = obj.name
row.selectableValue = obj.name
row.baseValue = obj.id
row.value = nil
}
}
this shows selectable list, but next code doensn't work as it should:
@IBAction func saveAction(sender: AnyObject) {
let section = self.form.sectionByTag("section") as? SelectableSection<ImageCheckRow<String>, String>
for obj in section!.selectedRows() {
print(obj.baseValue)
}
}
this prints name
field, but needs to print id
(row.baseValue = obj.id
).
Am i doing something wrong here?
Upvotes: 0
Views: 473
Reputation: 20804
I had been reviewing your code and I found this , seems that if we use SelectableSection
we need to use selectableValue
instead of baseValue
for our proposes, but I think that this is an bug from Eureka
because selectableValue
and baseValue
are the same although we set different values
you can mitigate this using row.selectableValue = obj.id
instead of row.selectableValue = obj.name
try this for Int
values in selectableValue
replace
<ImageCheckRow<String>, String>
for <ImageCheckRow<Int>, Int>
also replace section <<< ImageCheckRow<String>(obj.name)
for section <<< ImageCheckRow<Int>(obj.name)
and finally adjust saveAction as I do
@IBAction func saveAction(sender: AnyObject) {
let section = self.form.sectionByTag("section") as? SelectableSection<ImageCheckRow<Int>, Int>
for obj in section!.selectedRows() {
print(obj.baseValue)
}
}
this works for me with Int on selectableValue
The problem is this
public final class ImageCheckRow<T: Equatable>: Row<T, ImageCheckCell<T>>, SelectableRowType, RowType {
public var selectableValue: T?
required public init(tag: String?) {
super.init(tag: tag)
displayValueFor = nil
}
}
the selectableValue
is of type a pattern for any type you pass in declaration that is why <ImageCheckRow<Int>, Int>
resolve the problem with Int
I hope this helps you, regards
Upvotes: 1