Perhaps you should be calling the internetConnection function, rather
than comparing its address to 0x0000001 ?

if (internetConnection() == YES)
....


2009/12/15 Chunk 1978 <[email protected]>:
> i have been researching how to do this, and while i believe my code is
> correct, i always receive the alert stating the internet connection is
> unavailable.  what am i doing wrong?
>
> -=-=-=-=-
> - (BOOL)internetConnection
>        {
>        //INTERNET CONNECTION TESTING
>        //Add the SystemConfiguration framework
>        //#import <SystemConfiguration/SCNetworkReachability.h>
>        //#include <netinet/in.h>
>
>        //Create zero addy
>        struct sockaddr_in zeroAddress;
>        bzero(&zeroAddress, sizeof(zeroAddress));
>        zeroAddress.sin_len = sizeof(zeroAddress);
>        zeroAddress.sin_family = AF_INET;
>
>        //Recover reachability flags
>        SCNetworkReachabilityRef defaultRouteReachability =
> SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr
> *)&zeroAddress);
>        SCNetworkReachabilityFlags flags;
>
>        BOOL didRetrieveFlags =
> SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags);
>        CFRelease(defaultRouteReachability);
>
>        if (!didRetrieveFlags)
>                {
>                printf("Error. Could not recover network reachability 
> flags\n");
>                return 0;
>                }
>
>        BOOL isReachable = flags & kSCNetworkFlagsReachable;
>        BOOL needsConnection = flags & kSCNetworkFlagsConnectionRequired;
>        return (isReachable && !needsConnection) ? YES : NO;
>        }
>
> - (IBAction)gotoAppStore
>        {
>        if (internetConnection == YES)
>                [[UIApplication sharedApplication] openURL:[NSURL
> URLWithString:@"http://www.google.com";]];
>                else
>                {
>                UIAlertView *alert = [[UIAlertView alloc]       
> initWithTitle:nil
>                                                                        
> message:NSLocalizedString(SMConstNoInternetConnectionAlertMessage,
> nil)
>                                                                        
> delegate:self
>                                                                        
> cancelButtonTitle:@"OK"
>                                                                        
> otherButtonTitles:nil];
>                [alert show];
>                [alert release];
>                }
>        }
> -=-=-=-=-
> _______________________________________________
>
> Cocoa-dev mailing list ([email protected])
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/maillist%40steelskies.com
>
> This email sent to [email protected]
>
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to