Typically in iOS when creating UITableViewControll...
# kotlin-native
d
Typically in iOS when creating UITableViewController subclass, its easy to have that subclass implements the UITableViewDataSource and UITableViewDelegate protocols. When doing so in K/N I get a "Conflicting Overloads" error for
override fun tableView(tableView: UITableView, cellForRowAtIndexPath: NSIndexPath): UITableViewCell
from the data source protocol and
override fun tableView(tableView: UITableView, didSelectRowAtIndexPath: NSIndexPath)
from the delegate protocol . Is this a known issue and is there a work around besides putting the two methods in different classes?
g
Kotlin doesn’t allow you to implement the same method of different interfaces, it’s expected behaviour.
Instead you can implement one of the interfaces separately as anonymous class and delegate call to another implementation
👍 1
s
Actually in this case (when overriding Objective-C methods) these two methods are different, so it is possible to override both separately. The problem is that the compiler currently needs some help to accept it: try adding
@Suppress("CONFLICTING_OVERLOADS")
annotation to the class.
d
@svyatoslav.scherbina worked like a charm. Thx👍
g
Ha, Interesting, but why those methods are different? Looks like the same signature on Kotlin side?
s
Because those aren’t Kotlin methods, but Objective-C ones, and thus should have different overloading policy (based on selectors). Compiler frontend doesn’t know about this yet.
g
I see, interesting
d
Those two methods are also different with respect to the return type. Does K/N not take return type into consideration for method signatures?
s
Kotlin doesn’t, so the same is true for Kotlin/Native.
d
Good to know. Thanks.