Eureka: .insert() incorrect arguments

Created on 7 Feb 2019  路  4Comments  路  Source: xmartlabs/Eureka

_Environment: Eureka 4.3.1, Xcode 10.1 and iOS 12.1.3_

I am trying to insert a new row into a section, but I keep getting the following error:

form.sectionBy(tag: "section1").insert(LabelRow() at: 0)

Incorrect argument labels in call (have '_:at:', expected 'row:after:')

Strangely enough, this works:
form.rowBy(tag: "row1").section?.insert(LabelRow() at: 0)

Any ideas what am I doing wrong?

Most helpful comment

Found the issue: insert(_:at:) is a mutating function so you have to call it on a var.

Do this:

var s = form.sectionBy(tag: "section1")
s?.insert(LabelRow(), at: 0)

All 4 comments

It looks like a wrong error message. I think sectionBy(tag:) returns Optional, so you should put a ? after calling it. Did you try that?

Yes unfortunately, I even tried force-unwrapping it but no luck :(

Found the issue: insert(_:at:) is a mutating function so you have to call it on a var.

Do this:

var s = form.sectionBy(tag: "section1")
s?.insert(LabelRow(), at: 0)

So I believe the correct error message would be something like:
Cannot use mutating member on immutable value: 'sectionBy(tag:)' returns immutable value

Thanks for the quick answer!

Was this page helpful?
0 / 5 - 0 ratings