Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Duplicate tag when using custom object with PushRow #552

Closed
alexvazquez opened this issue Jul 11, 2016 · 13 comments
Closed

Error: Duplicate tag when using custom object with PushRow #552

alexvazquez opened this issue Jul 11, 2016 · 13 comments

Comments

@alexvazquez
Copy link

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?

@sunbohong
Copy link
Contributor

Can you supply one demo?

@alexvazquez
Copy link
Author

Here is the demo where you can see that it works using AlertRow but you get the Duplicate tag error when using PushRow.

Thanks

EurekaIssueDemo.zip

@mats-claassen
Copy link
Member

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?

@alexvazquez
Copy link
Author

alexvazquez commented Jul 12, 2016

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.

@mats-claassen
Copy link
Member

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...

@alexvazquez
Copy link
Author

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.

@mats-claassen
Copy link
Member

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

@alexvazquez
Copy link
Author

Let me try, and let you know... sounds terrific. 👍

@alexvazquez
Copy link
Author

Thanks it worked great!!.

@fatihtan
Copy link

fatihtan commented Nov 2, 2018

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...

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

@mats-claassen
Copy link
Member

Yes exactly. That is what I meant

@fatihtan
Copy link

fatihtan commented Nov 5, 2018

thank you.

@aaron-splicer
Copy link

aaron-splicer commented Dec 6, 2021

For anyone that might be googling for this bug, I had a similar problem when there was data to be selected from a list and there was duplicate data displayed on the list. Actually, I think it happened when there was the same name trying to be displayed in the second list on a single screen; not quite sure, but it was definitely caused by duplicate data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants