Simply change:
Reachability* wifiReach = [Reachability reachabilityForLocalWiFi];
to:
Reachability* wifiReach = [Reachability reachabilityForInternetConnection];
and
if (netStatus!=ReachableViaWiFi)
to:
if (netStatus == NotReachable)
In other words:
Reachability* wifiReach = [Reachability reachabilityForInternetConnection];
NetworkStatus netStatus = [wifiReach currentReachabilityStatus];
if (netStatus == NotReachable)
{
BTW - please consult an Objective-C tutorial to learn how to write compound expressions. Your if
statement would need to be something like:
if (netStatus!=ReachableViaWiFi && netStatus!=ReachableViaWWAN)
but while this will solve the compiler issue, it won't work for your code because the WWAN
value won't ever be given when using reachabilityForLocalWiFi
.