ios - To check wifi is on but no internet connectivity -



ios - To check wifi is on but no internet connectivity -

i m using reachability classes check wifi connectivity in code. problem arise wifi on there no or low net connectivity, here code runs in loop waiting response called webservice , hangsup , crashes sometimes. below code executed when nail ok on alertview pulls info webservice here code :

reachability *reachobj = [reachability reachabilityforinternetconnection]; [reachobj startnotifier]; networkstatus remotehoststatus = [reachobj currentreachabilitystatus]; if (remotehoststatus==reachableviawifi) { secondview *objsecview=[[secondview alloc]init]; [self presentmodalviewcontroller:objsecview animated:yes]; } else if (remotehoststatus==notreachable) { firstview *objfrstview=[[feedbackpopoverviewcontroller alloc]init]; [self presentmodalviewcontroller:objfrstview animated:yes]; }

guys m new objective c. plz help me out, in advance. , sorry grammatical mistakes.

try this..

scnetworkreachabilityflags flags; scnetworkreachabilityref reachability=scnetworkreachabilitycreatewithname(null, [@"your web sevice url" utf8string]); scnetworkreachabilitygetflags(reachability, &flags); bool reachable=!(flags & kscnetworkreachabilityflagsconnectionrequired); cfrelease(reachability); nsurlrequest *request=[nsurlrequest requestwithurl:[nsurl urlwithstring:urlstring]]; if([nsurlconnection canhandlerequest:request] && reachable) { conn=[nsurlconnection connectionwithrequest:request delegate:self]; if(conn) { //// } else { [_delegate performselector:@selector(httpdatadidfailloadingwithreason:) withobject:@"no net connection" afterdelay:0.1]; } } -(void) httpdatadidfailloadingwithreason:(nsstring*)reason { uialertview *alertview=[[uialertview alloc]initwithtitle:@"abc" message:reason delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alertview show]; [alertview release]; }

ios objective-c

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -