Skip to content

Instantly share code, notes, and snippets.

@mustafaibrahim989
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustafaibrahim989/b54d92d5a05d601e042f to your computer and use it in GitHub Desktop.
Save mustafaibrahim989/b54d92d5a05d601e042f to your computer and use it in GitHub Desktop.
//
// CheckConnection.h
// Youxel Technology
//
// Created by Mustafa Ibrahim on 10/3/12.
// Copyright (c) 2012 Youxel Technology. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Reachability.h"
@interface CheckConnection : NSObject
+(BOOL) checkInternetConnection;
+(BOOL)hasNetworkConnection;
@end
//
// CheckConnection.m
// Youxel Technology
//
// Created by Mustafa Ibrahim on 10/3/12.
// Copyright (c) 2012 Youxel Technology. All rights reserved.
//
#import "CheckConnection.h"
@implementation CheckConnection
+(BOOL)hasNetworkConnection
{
Reachability* reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
if(remoteHostStatus != NotReachable) {
return YES;
}
return NO;
}
+(BOOL) checkInternetConnection
{
// return YES;
Reachability* reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
if(remoteHostStatus != NotReachable) {
return YES;
}
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"" message:NSLocalizedString(@"Unable to connect to the internet. Please check your network and try again.", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil];
[alertView show];
return NO;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment