私のネットワークをオフにして、私のiosプログラムを実行します。 その後、プログラムを停止してください。NSURLConnectionを使用して接続できませんでした。どのように再接続しますか?
ネットワークの電源を入れた後。私のプログラムはまだ止まる。
iosでNSURLConnectionを再接続したいです。
-(void) applistDBdownload
{
NSString *file = [NSString stringWithFormat:@"http://sok129.cafxxx.com/oneapplist.sqlite3"];
NSURL *fileURL = [NSURL URLWithString:file];
NSURLRequest *req = [NSURLRequest requestWithURL:fileURL];
connect= [NSURLConnection connectionWithRequest:req delegate:self];
fileData = [[NSMutableData alloc] initWithLength:0];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"fail"); -> come in when network off.
-> no come in when network on
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
-> no come in when network on
-> come in when network off
}
1.私はどのように再接続しますか?このコード領域における
と
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
if(self.connect!=connection)
{
NSLog(@"noconnect");
return;
}
[self.fileData appendData:data];
}
- ネットワークをオフにした場合、どのように私は、このコードで取り扱うのですか?