से फ़ाइलों को डाउनलोड नहीं कर रहा है मेरे पास एक टेबलव्यू सेल सबक्लास में NSURLConnection
है जो अधिकांश फ़ाइलों को डाउनलोड कर सकता है। मैंने देखा, हालांकि, कुछ डाउनलोड करना शुरू करने में विफल रहता है, और समय समाप्त हो जाता है। एक उदाहरण this यूआरएल होगा, जो सिर्फ एक परीक्षण ज़िप फ़ाइल है जो किसी अन्य ब्राउज़र में ठीक डाउनलोड करता है। डाउनलोड के लिए मेरा कोड हैआईओएस NSURLConnection कुछ यूआरएल
-(void)downloadFileAtURL:(NSURL *)url{
self.downloadedData = [[NSMutableData alloc] init];
self.url = url;
conn = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:self.url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:1200.0] delegate:self startImmediately:YES];
}
- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSHTTPURLResponse*)response
{
int statusCode = [response statusCode];
if (statusCode == 200){
self.fileName.text = response.URL.lastPathComponent;
self.respo = response;
expectedLength = [response expectedContentLength];
}
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[self.downloadedData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
CFStringRef mimeType = (__bridge CFStringRef)[_respo MIMEType];
CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType, NULL);
CFStringRef extension = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassFilenameExtension);
NSString *fileName = [NSString stringWithFormat:@"%@.%@", [[_respo suggestedFilename] stringByDeletingPathExtension], (__bridge NSString *)extension];
[[NSFileManager defaultManager] createFileAtPath:[[self docsDir] stringByAppendingPathComponent:[NSString stringWithFormat:@"Downloads/%@", fileName]] contents:_downloadedData attributes:nil];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
NSLog(@"Download failed with error: %@", error);
}
कोई भी ऐसा कुछ देख सकता है जो इसका कारण हो सकता है?
यहाँ त्रुटि:
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x1fd2c650
{NSErrorFailingURLStringKey=http://download.thinkbroadband.com/10MB.zip,
NSErrorFailingURLKey=http://download.thinkbroadband.com/10MB.zip,
NSLocalizedDescription=The request timed out., NSUnderlyingError=0x1fdc90b0 "The request timed out."}
'कनेक्शन लागू करें: didFailWithError:' प्रोटोकॉल विधि और देखें कि आपको त्रुटि के रूप में क्या मिलता है। – Malloc
@ माल्कोक मेरे बुरे मैं इसे पोस्ट करना भूल गया। यह सिर्फ इतना कहता है कि कनेक्शन का समय समाप्त हो गया। –
ठीक है, तो आपको त्रुटि स्टैक क्या मिला है? – Malloc