- (BOOL) connectedToNetwork
{
NSString *requestString =@"";
NSData *requestData = [NSData dataWithBytes: [requestStr开发者_如何学JAVAing UTF8String] length: [requestString length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"http://www.google.com"]];
[request setHTTPMethod: @"POST"];
[request setTimeoutInterval:10];
[request setHTTPBody: requestData];
return [ NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ]!=nil;
}
and i got return TRUE sometimes though low connection..
How to solve this issue? Your suggestions are very helpful to me. Thanks in advancefor my application I use Reachability class from this Apple example. hope it helps )
http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
I would also recommend ASIHTTPRequest, which can help a lot with data downloading.
you must look into apple Reachability API's
Blog tutorial :
http://www.raddonline.com/blogs/geek-journal/iphone-sdk-testing-network-reachability/
http://www.xprogress.com/post-40-iphone-internet-connection-check-wifi-3g-edge-something-like-reachability-h/
精彩评论