checking of network
-(BOOL)checkNetworkConnection{
NSString *connectingString=[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://google.com"]];
if ([connectingString length]==0) {
NSLog(@"not connected");
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Error" message:@"Network is not available " delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
netWork=YES;
}
else {
netWork=NO;
}
[connectingString release];
return netWork;
}
-(BOOL)checkNetworkConnection{
NSString *connectingString=[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://google.com"]];
if ([connectingString length]==0) {
NSLog(@"not connected");
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Error" message:@"Network is not available " delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
netWork=YES;
}
else {
netWork=NO;
}
[connectingString release];
return netWork;
}
No comments:
Post a Comment