Check internet connection in cocoa application?

Apple has a nice code which does it for you. You can check if your connection is WiFi for instnace or just cell/WiFi link text.

Apple has a nice code which does it for you. You can check if your connection is WiFi for instnace or just cell/WiFi. Link text.

1 Yes, I'm using this for checking the connectivity for iPhone. My question was whether it will work for regular cocoa application either – Nava Carmon Jun 8 '10 at 15:56 developer.apple. Com/iphone/library/samplecode/Reachability/… says: Runtime Requirements: Mac OS X 10.5.3, iPhone OS 3.0, so my guess is yes.

– krzyspmac Jun 9 '10 at 10:02 The sample in this link is for iOS ONLY. This don't compile in OSX. If you look to the code there are "UITextFields" and other 'UI' stuf all over the place.

The 'Reachability' class won't work also as @dbainbridge explain in your post. – GojaN Aug 31 at 13:26.

This code will help you to find if internet is reachable or not: -(BOOL)isInternetAvail { BOOL bRet = FALSE; const char *hostName = @"google. Com" cStringUsingEncoding:NSASCIIStringEncoding; SCNetworkConnectionFlags flags = 0; if (SCNetworkCheckReachabilityByName(hostName, &flags) && flags > 0) { if (flags == kSCNetworkFlagsReachable) { bRet = TRUE; } else { } } else { } return bRet; } For more information you can look at the iphone-reachability.

– Nava Carmon Jun 8 '10 at 9:07 This will work for cocoa. For iphone you might have replace the flags and method name based on SDK documentation. – Unicorn Jun 8 '10 at 9:25 thanks, will try it out – Nava Carmon Jun 8 '10 at 11:41.

The current version of Reachability code (2.2) listed on Apple's site and referenced above does NOT compile as-is for a Mac OS X Cocoa application. The constant kSCNetworkReachabilityFlagsIsWWAN is only available when compiling for TARGET_OS_IPHONE and Reachability. M references that constant.

You will need to #ifdef the two locations in Reachability. M that reference it like below: #if TARGET_OS_IPHONE (flags & kSCNetworkReachabilityFlagsIsWWAN)? 'W' : '-', #endif and #if TARGET_OS_IPHONE if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) { // ... but WWAN connections are OK if the calling application // is using the CFNetwork (CFSocketStream?) APIs.

RetVal = ReachableViaWWAN; } #endif.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions