Pdf dosyasını indirmek istiyorum. Küçük pdf dosyası indirdiğimde artı değer elde ederim ama büyük dosya indirdiğimde afnetworking kullanarak eksi değer elde ediyorum. totalBytesExpectedToRead
olduğunu Olumsuz değer Progress Block Dosya indirme sırasında
- (IBAction)download:(id)sender {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@""]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
NSString *pdfName = @"The_PDF_Name_I_Want.pdf";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:pdfName];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
NSLog(@"Download = %f", (float)totalBytesRead/totalBytesExpectedToRead);
self.progressView3.progress = (float)totalBytesRead/totalBytesExpectedToRead;
}];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Successfully downloaded file to %@", path);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[operation start];
}
2016-04-06 15:04:53.842 pdf[8149:60b] Download = -811521.000000
2016-04-06 15:04:53.849 pdf[8149:60b] Download = -817179.000000
2016-04-06 15:04:53.860 pdf[8149:60b] Download = -819123.000000
2016-04-06 15:04:53.872 pdf[8149:60b] Download = -823469.000000
2016-04-06 15:04:53.879 pdf[8149:60b] Download = -826393.000000
2016-04-06 15:04:53.921 pdf[8149:60b] Download = -827820.000000
2016-04-06 15:04:53.932 pdf[8149:60b] Download = -830744.000000
2016-04-06 15:04:53.939 pdf[8149:60b] Download = -833662.000000
benim sorunu çözmek lütfen benim çıkışını ... loglarınız gösterdiği gibi
Değerler ("totalBytesRead" ve "totalBytesExpectedToRead") nedir? Biri olumsuz olabilir, hangisi? Ya da döküm bir sorundur. – Larme
burada bu negatif değer (float) toplamBytesRead/totalBytesExpectedToRead – iOS
Biliyorum, koyduğunuz günlükleri anladım, ama her bir değeri göz önünde bulundurarak bunlardan biri negatif mi? Şamandıra olarak mı? Uzun süre mi? – Larme