xxfast
10/25/2024, 11:15 PMBool
, but on my end i'm seeing KotlinBoolean
__attribute__((swift_name("KotlinBoolean")))
@interface AppBoolean : AppNumber
- (instancetype)initWithBool:(BOOL)value;
+ (instancetype)numberWithBool:(BOOL)value;
@end
Does anyone know why? 🤔curioustechizen
10/29/2024, 6:42 AMBoolean
and is consumed by Swift, then Swift sees it as a Bool
• If I have a Kotlin property or function that I want Swift to implement, then the return type becomes KotlinBoolean
Not sure if this is intended.curioustechizen
10/29/2024, 6:44 AM//Kotlin
data class MyUiState(
val name: String,
val loggedIn: Boolean
)
Then I can do this
// Swift
if myUiState.loggedIn {
doSomething()
}
curioustechizen
10/29/2024, 6:47 AM// Kotlin
interface UserRepository {
fun getName(): String
fun isLoggedIn(): Boolean
}
Then I need to implement it like this in Swift. Notice how the return type of isLoggedIn became KotlinBoolean
// Swift implementation
class IosUserRepository: UserRepository {
func getName() -> String {
return "John Doe"
}
func isLoggedIn() -> KotlinBoolean {
let loggedIn = figureItOut()
return KotlinBoolean(bool: loggedIn)
}
}
curioustechizen
10/29/2024, 6:48 AM.boolValue
at the end:
// Swift usage
let userRepository = IosUserRepository()
if userRepository.isLoggedIn().boolValue {
doSomething()
}
xxfast
10/29/2024, 10:49 PM