Created
December 5, 2020 17:59
-
-
Save hardik-trivedi/f7ad2e4ab728a297254afb5119fa39d1 to your computer and use it in GitHub Desktop.
Usage of expect/actual keyword in KMM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:shared:commonMain:OSInformation.kt | |
expect fun getOSInformation(): String | |
:shared:androidMain:OSInformation.kt | |
actual fun getOSInformation(): String { | |
print(Build.VERSION_CODES::class.java.fields) | |
return "${Build.VERSION_CODES::class.java.fields[Build.VERSION.SDK_INT].name} ${Build.VERSION.SDK_INT}" | |
} | |
:shared:iOSMain:OSInformation.kt | |
actual fun getOSInformation(): String { | |
return "${platform.UIKit.UIDevice.currentDevice.systemName()} ${platform.UIKit.UIDevice.currentDevice.systemVersion}" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment