Erik Ziegler
09/09/2024, 6:26 PM+
) from a Kotlin Multiplatform class in iosMain? Setting the method on the companion object does not create a class method although the docs say so. Instead it lands in the separete Companion class.
class MyTest {
companion object {
fun test() = "Hello from iOS"
}
}
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("MyTest")))
@interface SharedMyTest : SharedBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
@property (class, readonly, getter=companion) SharedMyTestCompanion *companion __attribute__((swift_name("companion")));
@end
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("MyTest.Companion")))
@interface SharedMyTestCompanion : SharedBase
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
+ (instancetype)companion __attribute__((swift_name("init()")));
@property (class, readonly, getter=shared) SharedMyTestCompanion *shared __attribute__((swift_name("shared")));
- (NSString *)test __attribute__((swift_name("test()")));
@end
Does anyone know if it is possible to actually get a class method in Obj-C?Erik Ziegler
09/09/2024, 6:27 PM