I am using the Eureka plugin for xcode swift and having an issue with the app crashing when selecting option "OTHER". It's supposed to have a TextRow below the date if "OTHER" is selected.
Error: Thread 1: Assertion failed: Duplicate tag segments
I'm pretty sure the issue is with <<< SegmentedRow<String>("segments"){
not being incremented "segments1", "segments2", etc... with each looped row. Also I do not know how I could make the $0.hidden
line work if segments had to be incremented: $0.hidden = "$segments != 'OTHER'"
form
+++ Section()
for (index, date) in fdates.enumerated() {
form.last!
<<< SegmentedRow<String>("segments"){
$0.title = date
$0.options = ["FULL", "AM", "PM", "OTHER"]
$0.value = "FULL"
}.cellUpdate { cell, row in
cell.segmentedControl.setContentHuggingPriority(.defaultHigh, for: .horizontal)
if (self.type == "Lieu") {
cell.segmentedControl.setWidth(CGFloat(47), forSegmentAt: 0)
cell.segmentedControl.setWidth(CGFloat(40), forSegmentAt: 1)
cell.segmentedControl.setWidth(CGFloat(40), forSegmentAt: 2)
cell.segmentedControl.setWidth(CGFloat(57), forSegmentAt: 3)
}
//print(index)
}
+++ Section(){
$0.tag = "other_\(index)"
$0.hidden = "$segments != 'OTHER'"
}
<<< TextRow(){
$0.title = "This will be changed to a time picker after..."
}
}
** EDIT ** I managed to stop the crashing by using the index row with "segments" but the TextRow still doesn't show up when clicking "OTHER":
let tag = "segments\(index)"
<<< SegmentedRow<String>(tag){
+++ Section(){
$0.tag = "other\(index)"
$0.hidden = Condition(stringLiteral: "$segments\(index) != 'OTHER'")
}
The author told me to move the form +++ Section()
into the loop just before <<< SegmentedRow<String>(tag){
and this works.
for (index, date) in fdates.enumerated() {
form +++ Section()
let tag = "segments\(index)"
<<< SegmentedRow<String>(tag){
$0.title = date