Hi,
I have been using custom objects with AlertRow without any problem.
Now, I tried to change AlertRow with PushRow and I get the following error:
assertion failed: Duplicate tag DashPress.ServicePaymentRate: file /Users/demo/Documents/Development/Swift/Dashboard/dashboard main/Pods/Eureka/Source/Core/BaseRow.swift, line 146
Here is the code:
<<< PushRow<ServicePaymentRate>() {
$0.title = "Payment Rate"
$0.selectorTitle = "Payment Rate"
$0.options = self.servicePaymentRates
$0.displayValueFor = {
if let t = $0 {
return t.description
}
return nil
}
}.onChange { row in
print(row.value)
}
Any clue on why Im getting this error using PushRow but it's working without error with AlertRow?
Can you supply one demo?
Here is the demo where you can see that it works using AlertRow but you get the Duplicate tag error when using PushRow.
Thanks
This is strange. That error pops up when you are defining two rows with the same tag. Can you double check that you are not doing that?
I just give both rows difrerent tags and the issue still there:
<<< AlertRow<ServicePaymentRate>() {
$0.tag = "tag1"
$0.title = "Payment Rate"
$0.selectorTitle = "Select a Payment Rate"
$0.options = self.servicePaymentRates
$0.displayValueFor = {
if let t = $0 {
return t.description //t.map({ countries[$0]! }).joinWithSeparator(", ")
}
return nil
}
//$0.value = 馃懄馃徏
}.onChange { row in
print(row.value)
}
.onPresent{ _, to in
//to.view.tintColor = .purpleColor()
//to.dispayValueFor = { return "Hi \($0)" }
}.cellUpdate { cell, row in
//row.options = self.careTypes.map { $0.description }
}
<<< PushRow<ServicePaymentRate>() {
$0.tag = "tag2"
$0.title = "Payment Rate (pushrow)"
$0.options = self.servicePaymentRates
}
Seems for me that the error comes when trying to build all the rows for the pushrow array and it gives the same tag to each row. That's what I think.
It works if you declare your class ServicePaymentRate to be CustomStringConvertible.
This is because the default implementation of SelectorViewController uses String(option) as the tag for your PushRow rows. Your options would all return "EurekaIssueDemo.ServicePaymentRate".
It would still fail if you have several objects with the same description...
Well if I convert that to CustomStringConvertible yes it works but then on the onChange() event I get a string as row.value instead of my object. In AlertRow it works the way it should be because I get the entire object and then I can select any property of that in case I need it.
Any clue Mats? Appreciate it.
No in onChange you should get the correct value.
Just if you print like print(row.value) it will print the string representation but row.value is still your object.
Try printing row.value?.paymentPercentage in onChange
Let me try, and let you know... sounds terrific. 馃憤
Thanks it worked great!!.
It works if you declare your class ServicePaymentRate to be
CustomStringConvertible.
This is because the default implementation ofSelectorViewControllerusesString(option)as the tag for your PushRow rows. Your options would all return "EurekaIssueDemo.ServicePaymentRate".
It would still fail if you have several objects with the same description...
Hi @mats-claassen
You say declare your class ServicePaymentRate to be "CustomStringConvertible". Did you mean My class should implement the "CustomStringConvertible" protocol?
Thank you for help
Yes exactly. That is what I meant
thank you.
Most helpful comment
It works if you declare your class ServicePaymentRate to be
CustomStringConvertible.This is because the default implementation of
SelectorViewControllerusesString(option)as the tag for your PushRow rows. Your options would all return "EurekaIssueDemo.ServicePaymentRate".It would still fail if you have several objects with the same description...