I am trying to get the network status via the following code
//define in my .h file
NetworkStatus internetConnectionStatus;
//define in my .m file
self.internetConnectionStatus = [[Reachability reachabilityForInternetConnection]currentReachabilityStatus];
I am getting self.internetconnection status = <null>. What am I doing wrong here?
You should compare the value of it to the enum values defined in
Reachability.h:Also, make sure your NetworkStatus has an
@property (nonatomic, assign)for it in your header if you’re usingself.to get/set it.In my opinion though, assuming you’re using the Apple Reachability sample, it’s not particularly refined and could possibly be giving an erroneous value in some circumstances. For a more robust version, use either the version that ships with the
ASIHTTPRequestlibrary, or the version which it is based on, which is available for download here and detailed in this blog post.