is there any way to access ios swift UIViewControl...
# touchlab-tools
a
is there any way to access ios swift UIViewController in KMM. I have feature which is written in native ios using swift and want to access in KMM project. Can any one help me here
k
Well, not really a "touchlab" question, but here are the basics. An instance of
UIViewController
is really Objc and not Swift. Kotlin has already "mapped" that, so you should be able to pass that in and interact with it from Kotlin. However, I assume you mean an instance of
UIViewController
that you've extended and added functionality to. That could get complex with cinterop. As an alternative, create an interface in Kotlin that defines functions you'd like to call on your instance of
UIViewController
, then implement the Kotlin interface in Swift. You can pass that back into KMM and call those functions. No cinterop required.
a
@kpgalligan Thanks you for the suggestion I'll try this approach.