#import "RootViewController.h"
Add header File
#import "Reachability.h"
@interface Rootviewcontroller ()
@end
@implementation Rootviewcontroller
-(ID) Initwithnibname: (NSString *) Nibnameornil Bundle: (NSBundle *) Nibbundleornil
{
self = [super Initwithnibname:nibnameornil Bundle:nibbundleornil];
if (self) {
Custom initialization
}
return self;
}
-(void) viewdidload
{
[Super Viewdidload];
Do any additional setup after loading the view.
if ([self isconnectionavailable]) {
Uialertview *alert=[[uialertview alloc]initwithtitle:@ "Reminder" message:@ "Network is connected, please resend" delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK", nil];
[Alert show];
};
}
#pragma-mark-functions
Determine if the network is connected.
-(BOOL) isconnectionavailable{
BOOL isexistencenetwork = YES;
reachability *reach = [reachability reachabilitywithhostname:@ "www.apple.com"];
switch ([reach Currentreachabilitystatus]) {
Case Notreachable:
Isexistencenetwork = NO;
NSLog (@ "notreachable");
Break
Case Reachableviawifi:
Isexistencenetwork = YES;
NSLog (@ "WIFI");
Break
Case Reachableviawwan:
Isexistencenetwork = YES;
NSLog (@ "3G");
Break
}
if (!isexistencenetwork) {
Uialertview *alert=[[uialertview alloc]initwithtitle:@ "Reminder" message:@ "network is not connected, please resend" delegate:self cancelbuttontitle:@ "Cancel" otherbuttontitles:@ "OK", nil];
[Alert show];
}
return isexistencenetwork;
}
Determine if there is no network