I was trying use the code given here Reachability sample code. But am facing some problems to do this. To use the code I have downloaded Reachability.h and Reachability.m from here. But whenever I try to compile it fails to recognize Reachability class. The code block which causes the problem are given below -
Reachability *reachability = [Reachability reachabilityForInternetConnection]; // in this line it doesn't recognize "Reachability"
[reachability startNotifier];
NetworkStatus status = [reachability currentReachabilityStatus]; // In this line it doesn't recognize "NetworkStatus"
if(status == NotReachable)
{
//No internet
}
else if (status == ReachableViaWiFi)
{
//WiFi
}
else if (status == ReachableViaWWAN)
{
//3G
}
Please note that I am using this code in iOS block in a cross platform C++ library solution. I need to resolve this issue as soon as possible. I am seeking for help to resolve the issue?
EDIT:
Build error is resolved after I have added condition check for OBJC macro. But it seems the code doesn't get compiled. Here is the edited code
#ifdef __OBJC__
Reachability *reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];
NetworkStatus status = [reachability currentReachabilityStatus];
if(status == NotReachable)
{
//No internet
}
else if (status == ReachableViaWiFi)
{
//WiFi
}
else if (status == ReachableViaWWAN)
{
//3G
}
#endif
I want to use the above code and also want to compile the code. How to do that?
The issue is fixed. I have fixed the issue by using the core code of Reachability framework. If anyone faces the same issue I can help.
The issue was occurring because "NotReachable", "ReachableViaWifi" and "ReachableViaWWAN" are user defined enum. It is not included in "Rechability.h". So, I have downloaded a project on Reachability framework and find out the real system flag for these values. And solved the issue.