nw_interface_radio_type_t

我想用Network.framework中path_monitor来监听网络状态的变化,在Network.framework的interface.h中有一个枚举定义nw_interface_radio_type_t,我没有找到关于它的使用方法。

I want to use path_monitor in Network.framework to monitor changes in network status. There is an enumeration definition nw_interface_radio_type_t in interface.h of Network.framework. I have not found how to use it.

Replies

https://developer.apple.com/forums/thread/748336

nw_interface_radio_type_t is used by the connection report mechanism. Specifically, when running a connection you can get a report that includes the radio type. To get the value, call nw_data_transfer_report_get_path_radio_type.

If you’re using Swift, you do this using the radioType property.

Note that this is tied to the report mechanism because such things can change dynamically and so it makes sense to look at the value that was used for your connection. If you’re interested in WWAN, Core Telephony has mechanism to get the radio technology in use right now, namely the serviceCurrentRadioAccessTechnology property.

Finally, a general warning about this stuff: It’s fine to use it for logging and so on, but I recommend that you not use it for making decisions about how to use the network. That’s because you can’t draw conclusion about the network’s behaviour from low-level parameters like this. I talk about this, for a similar situation, in my iOS Network Signal Strength post. And we explain how you should do this in the recent Adapt to changing network conditions tech talk.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"