magnumrocha
01/05/2021, 6:08 PM@kotlinx.cinterop.internal.CCall public external fun SCNetworkReachabilityGetFlags(target: platform.SystemConfiguration.SCNetworkReachabilityRef? /* = kotlinx.cinterop.CPointer<cnames.structs.__SCNetworkReachability>? */, flags: kotlinx.cinterop.CValuesRef<platform.SystemConfiguration.SCNetworkReachabilityFlagsVar /* = kotlinx.cinterop.UIntVarOf<kotlin.UInt> */>?): kotlin.Boolean { /* compiled code */ }
to receive the kSCNetworkReachabilityFlags…
correctly?
in Swift, we can make the call:
var flags: SCNetworkReachabilityFlags = []
if !SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags) {
return false
}
And receive the flags in an array style….
In Kotlin Native, I am doing:
// val flags = allocArray<SCNetworkReachabilityFlagsVar>(10) // -> this was my first attempt, they are 10 possible flags!
val flags = alloc<SCNetworkReachabilityFlagsVar>()
if (!SCNetworkReachabilityGetFlags(reachabilityRef, flags.ptr)) return false
the problem is I am receiving all the flag “summed” (they are kotlin.UInt
), and not split in an array, like in Swift.