https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
k

kevin.cianfarini

03/05/2024, 2:31 PM
If I wanted to expose a Kotlin interface in Swift as
AnyObject
, what would that be in Kotlin?
Any
in Kotlin is just
Any
in swift. Would it be
Any?
j

Jeff Lockhart

03/05/2024, 6:22 PM
AnyObject
in Swift is the same as the
id
type in Objective-C. I believe an
abstract class
in Kotlin should satisfy
AnyObject
, as Kotlin classes will inherit from the
NSObject
base class.
k

kevin.cianfarini

03/05/2024, 7:01 PM
Yeah so turned out that just using a random class other than
Any
worked, which was a bit weird.
j

Jeff Lockhart

03/05/2024, 7:26 PM
Yeah,
Any
in Swift basically expands on
AnyObject
from Objective-C. Any class from Objective-C or Swift should satisfy
AnyObject
. But besides classes, structs, enums, and function types in Swift satisfy
Any
, a superset of
AnyObject
.