https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
d

Diogo Ribeiro

03/06/2019, 1:27 PM
Hi guys, somebody is working on an UI library? I cannot override UITableViewDataSource property on kotlin. What am I doing wrong? Is it supported?
m

marstran

03/06/2019, 1:27 PM
What's the error message?
d

Diogo Ribeiro

03/06/2019, 1:28 PM
s

sitepodmatt

03/06/2019, 1:40 PM
Not familar with the platform but the error suggests return type needs to be boolean and you're return UITableViewCell and NSInteger instead of a Boolean
j

Jonas Bark

03/06/2019, 1:50 PM
declaration is fine for iOS, but I'm not sure about the syntax
1. are you sure you want a UITableView and not a UITableViewController? 2.
Copy code
class TableViewTest : UITableView() {

    override fun cellForRowAtIndexPath(indexPath: NSIndexPath): UITableViewCell? {
        return super.cellForRowAtIndexPath(indexPath)
    }
}
works fine
d

Diogo Ribeiro

03/06/2019, 1:57 PM
yes, it right...but I want to use the UITableViewDelegate and UITableViewDatasource here as well.
n

nestserau

03/06/2019, 1:59 PM
It doesn’t get what
UITableViewCell
is. Are your imports correct?
d

Diogo Ribeiro

03/06/2019, 2:03 PM
yes... import platform.UIKit.*
s

Sam

03/06/2019, 4:19 PM
Seems the compiler is getting confused. You can add
@Suppress("RETURN_TYPE_MISMATCH_ON_OVERRIDE")
to the top of your class and it should compile. One other note, there's no technical reason you can't have a subclass of a tableview act as its own data source or delegate but it isn't a practice looked favorably upon by other iOS developers. The most common practice is to have the
UIViewController
controlling the tableview act as the data source and delegate. It's also acceptable to encapsulate that logic into separate class that conforms to one or both of those protocols.
👍 1
d

drofwarcs

03/06/2019, 4:40 PM
as a side note, since your InnoFormTable is a subclass of NSObject (indirectly), this class will not be accessible from Objective-C or Swift. Just a heads up in case you were planning on sharing this as a framework.
👍 1
j

josephivie

03/06/2019, 5:38 PM
To answer your first question, yes, I am currently working on https://github.com/lightningkite/koolui, but I haven't done iOS yet.
💯 1
d

Diogo Ribeiro

03/07/2019, 9:31 AM
Thanks guys! Yeah, I understand that Sam. I was testing out the code. My idea is to build a Tableview/Recyclerview dynamically in Kotlin for a Form Builder.