Question

How does the iOS Reachability class work, and what's so special about the IP Address 169.254.0.0?

I'm trying to figure out whether Wi-Fi is on, independent of whether it is connected to an actual Wi-Fi network or not.

I haven't found a satisfactory answer for this question on SO, and even the answers that try to answer this don't work for me.

Was it helpful?

Solution

When you fail to get an IP address from DHCP, it will automatically assign you a random address in the 169.254.x.x range. So if you have an IP address like this, it means you're connected to a network, and set to use DHCP to get an address, but it is unable to obtain an IP address from DHCP.

There doesn't appear to be any way to simply detect if wifi is enabled and not connected to a network, so I think you're out of luck there. The best you can do is detect if you're connected to a wifi network, but often if you're out and about, you won't be connected to a wifi network even though it is enabled.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top