You need to create a label
with file download percentages from 0 to 100 using this code.
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite;{ dispatch_async(dispatch_get_main_queue(), ^{ [self.progressView setProgress:totalBytesWritten/totalBytesExpectedToWrite animated:YES]; }
Tried to create, but this code does not work - in the text label
I receive (null)
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite;{ dispatch_async(dispatch_get_main_queue(), ^{ NSString *percentage = [NSString stringWithFormat:@"%@%", (int)(totalBytesWritten/totalBytesExpectedToWrite)*100]; _label = [[UILabel alloc]initWithFrame:CGRectMake(91, 15, 500, 50)]; [_label setText: percentage]; _label.numberOfLines = 1; _label.backgroundColor = [UIColor blackColor]; _label.textColor = [UIColor whiteColor]; _label.textAlignment = NSTextAlignmentCenter; [self.view addSubview:_label]; }); }
How to create a label
with percent load?