大量のデータを含む応答を要求しています。しかし、何度も何度も接続が失われます.インターネットは正常に機能しています.しかし、それでも接続が失われますエラー:-エラードメイン= NSURLErrorドメインコード=-1001「要求がタイムアウトしました。」
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
if (theConnection) {
receivedData = [[NSMutableData data] retain];
} else {
NSLog(@"Connection Failed!");
appDel.Internet_connected=FALSE;
[MainHandler performSelector:self.targetSelector_loseconenction];
}
(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[receivedData setLength:0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[receivedData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
//[connection release];
NSLog(@"Connection Failed!");
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
appDel.Internet_connected=TRUE;
NSString *responseString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
NSString *valueToSave = responseString;
[[NSUserDefaults standardUserDefaults]
setObject:valueToSave forKey:@"responce"];
NSString *savedValue = [[NSUserDefaults standardUserDefaults]
stringForKey:@"responce"];
NSDictionary *result = [savedValue JSONValue];
}