iOS: Initialising NSIndexPath for UITableView

Hi there!

Does anyone of you know, how to initialise the NSIndexPath from the Foundation-Framework for the interaction with UITableView in Kotlin native?

In iOS the NSIndex from the Foundation-Framework gets extended by UIKit and AppKit to supply specialized names for the first two index path nodes for use when working with table views and collection views. source

NSIndexPath(row: Int, section: Int)

However in the compiled Foundation-Framework code of Kotlin native, I’m not able to find this initialisation.

Does anyone of you came across the same and knows a decent workaround? :slight_smile:

This is most likely to do with the fact that there are two constructors with the same parameter types differentiated only by parameter name. Try using named parameters in your call, ie (row = 10, section = 20) to make it explicit which one you want to call.

If that doesn’t work then there might be a bug in the API conversion or overloading resolution.

Unfortunately this doesn’t work.

However I wonder, why I can access NSIndexPath.row and NSIndexPath.section, though those are extensions of the UIKit-Framework as it should be the NSIndexPath(row: Int, section: Int), too.

The actual declaration in Objective-C uses different names (indexPathForRow and indexPathForItem) for those methods they will be the ones that Kotlin uses, so you should try those. Select Objective-C as the language at the top of the page you linked to see those declarations.

I’m not sure what you mean by your second paragraph but NSIndexPath.row and NSIndexPath.section are properties and you can set those instead of using the initializer if that works for you.