magnumrocha
01/05/2021, 6:15 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.russhwolf
01/05/2021, 8:42 PMallocArrayOf()
magnumrocha
01/06/2021, 10:18 AMallocArrayOf()
needs a vargarg
as a parameter, how could I use it?magnumrocha
01/11/2021, 5:20 PM