Oleg G. Oleg G. - 5 months ago 17
Swift Question

Eureka lib in swift: How can i loop rows?

Maybe it's a useless question but, i'm trying to make a "for loop" with labelRow,
but it don't do what i want .. :/

i wanna the same things like the example project of Eureka with SegmentedRow, but in segment i want to do a loop for rows.

Can someone guide me ?

thanks !!

ps:

thats what i try in view did load:

self.form = Section()
<<< SegmentedRow<String>("segments"){
$0.options = ["Passées", "En cours", "Futures"]
$0.value = "En cours"
}

+++ Section(){
$0.tag = "past_s"
$0.hidden = "$segments != 'Passées'" // .Predicate(NSPredicate(format: "$segments != 'Sport'"))
}

for it in self.past {
self.form.last! <<< TextRow() { row in
row.title = "Which is your favourite soccer player?"
}
}

self.form +++= Section(){
$0.tag = "waiting_s"
$0.hidden = "$segments != 'En cours'"
}

for it in self.waiting {
self.form.last! <<< TextRow() { row in
row.title = "Which is your favourite soccer player?"
}
}

self.form +++= Section(){
$0.tag = "futur_s"
$0.hidden = "$segments != 'Futures'"
}

for it in self.future {
self.form.last! <<< TextRow() { row in
row.title = "Which is your favourite soccer player?"
}
}


and thats what i'm waiting :)

self.form = Section()
<<< SegmentedRow<String>("segments"){
$0.options = ["Passées", "En cours", "Futures"]
$0.value = "En cours"
}

+++ Section(){
$0.tag = "past_s"
$0.hidden = "$segments != 'Passées'" // .Predicate(NSPredicate(format: "$segments != 'Sport'"))
}

<<< LabelRow() { row in
row.title = "1"
}

<<< LabelRow() { row in
row.title = "temp"
}

+++ Section(){
$0.tag = "waiting_s"
$0.hidden = "$segments != 'En cours'"
}

<<< LabelRow() { row in
row.title = "2"
}

<<< LabelRow() { row in
row.title = "temp"
}

+++ Section(){
$0.tag = "futur_s"
$0.hidden = "$segments != 'Futures'"
}

<<< LabelRow() { row in
row.title = "3"
}

<<< LabelRow() { row in
row.title = "temp"
}


i ve tried that too (and a lot of others ways):

form +++ Section()
form.last! <<< SegmentedRow<String>("segments"){
$0.options = ["Passées", "En cours", "Futures"]
$0.value = "En cours"
}

form +++= Section(){
$0.tag = "past_s"
$0.hidden = "$segments != 'Passées'"
}

for past in self.past {
form.last! <<< LabelRow() { row in
row.title = "1"
}
}


and try this too :

form = Section()
<<< SegmentedRow<String>("segments"){
$0.options = ["Passées", "En cours", "Futures"]
$0.value = "En cours"
}

form +++ self.pastSection!
form +++ self.waitingSection!
form +++ self.futurSection!

self.pastSection = Section("past_s") {
$0.tag = "past_s"
$0.hidden = "$segments != 'Passées'"
}

self.waitingSection = Section("waiting_s") {
$0.tag = "waiting_s"
$0.hidden = "$segments != 'En cours'"
}

self.futurSection = Section("futur_s") {
$0.tag = "futur_s"
$0.hidden = "$segments != 'Futures'"
}

for past in self.past {
self.pastSection!
<<< LabelRow() {
$0.title = "test"
}
}

for waiting in self.waiting {
self.waitingSection!
<<< LabelRow() {
$0.title = "test"
}
}

for futur in self.future {
self.futurSection!
<<< LabelRow() {
$0.title = "test"
}
}

form +++ self.pastSection!
form +++ self.waitingSection!
form +++ self.futurSection!


but i've got an error like this photo of error

Answer

finally i found the answer !

form.delegate = nil
    form.removeAll()

    form +++= Section("DuplicateCounter") { row in row.tag = "DuplicateCounter" }

        <<< SegmentedRow<String>("segments"){
            $0.options = ["Passées", "En cours", "Futures"]
            $0.value = "En cours"
    }

    self.pastSection = Section("past_s") {
        $0.tag = "past_s"
        $0.hidden = "$segments != 'Passées'"
    }

    self.waitingSection = Section("waiting_s") {
        $0.tag = "waiting_s"
        $0.hidden = "$segments != 'En cours'"
    }

    self.futurSection = Section("futur_s") {
        $0.tag = "futur_s"
        $0.hidden = "$segments != 'Futures'"
    }

    form +++ self.pastSection!
    form +++ self.waitingSection!
    form +++ self.futurSection!

    for past in self.past {
        self.pastSection!
            <<< LabelRow("\(past.id)") {
                $0.title = "test"
        }
    }

    for waiting in self.waiting {
        self.waitingSection!
            <<< LabelRow("\(waiting.id)") {
                $0.title = "test"
        }
    }

    for futur in self.future {
        self.futurSection!
            <<< LabelRow("\(futur.id)") {
                $0.title = "test"
        }
    }

thanks for reading :) see ya