MJegorovas
12/09/2021, 2:13 PM- (void) MonitorWifiInterface
{
m_pathMonitor = nw_path_monitor_create();
nw_path_monitor_set_update_handler(m_pathMonitor, ^(nw_path_t _Nonnull path) {
NSLog(@"[NetInterfaceUtilies] Network path changed");
});
nw_path_monitor_start(m_pathMonitor);
}
Have no idea what to do in ^(nw_path_t _Nonnull path)
partMJegorovas
12/09/2021, 2:15 PMactual class NetworkStatus {
private val monitor = nw_path_monitor_create()
private var path = nw_path_t()
init {
println("NETWORK: $path")
nw_path_monitor_set_update_handler(monitor, path as nw_path_monitor_update_handler_t)
nw_path_monitor_start(monitor)
}
actual fun isNetworkAvailable(): Boolean {
return nw_path_get_status(path) == nw_path_status_satisfied
}
}
but on cast I get error kotlin.ClassCastException: null cannot be cast to kotlin.Function1
MJegorovas
12/13/2021, 2:08 PMactual class NetworkStatus {
private val monitor = nw_path_monitor_create()
private var path: nw_path_t = null
init {
nw_path_monitor_set_update_handler(monitor) { path ->
this.path = path
}
nw_path_monitor_start(monitor)
}
actual fun isNetworkAvailable(): Boolean {
return nw_path_get_status(path) == nw_path_status_satisfied
}
}