I use this code to download the file.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"Chapter1.mp3"]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath isDirectory:NO]; if (!fileExists) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSString *stringURL = @"https://drive.google.com/uc?export=download&id=0B_mHRsv5WQu6d3plcTlHV2VmaGg"; NSURL *url = [NSURL URLWithString:stringURL]; NSData *urlData = [NSData dataWithContentsOfURL:url]; [urlData writeToFile:filePath atomically:YES]; if (!fileExists) { [self performSegueWithIdentifier: @"detailSegue" sender: self]; } }); } 

Need a round progresView to see the file upload process. Tried to do, but something does not work. How can this be done?

UPD

Everything is working. But the animation of the process is not visible (the progresView abruptly turns blue when the download is complete)

 UIProgressView *progressView = [[UIProgressView alloc] init]; progressView.frame = CGRectMake(100,100,100,20); [self.view addSubview:progressView]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"Chapter1.mp3"]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath isDirectory:false]; if (!fileExists) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSString *stringURL = @"https://drive.google.com/uc?export=download&id=0B_mHRsv5WQu6Q0V0eEJxSWk0NGg"; NSURL *url = [NSURL URLWithString:stringURL]; NSData *urlData = [NSData dataWithContentsOfURL:url]; [urlData writeToFile:filePath atomically:YES]; float progress = [urlData length]/(float)[urlData length]; [progressView setProgress:progress]; if (progress == 1.0){ } }); } 
  • and what UIActivityIndicatorView not like? - Max Mikheyenko
  • Can I show the download process in it? No matter what to use. The main thing to see the download process. - User
  • aah, that's what you need. look at the githaba, there are so many of them - Max Mikheyenko

1 answer 1

There are a lot of them here, choose any - https://www.cocoacontrols.com/search?q=progress

  • Updated the question. - User
  • update progress in the main flow: dispatch_async (dispatch_get_main_queue (), ^ {[progressView setProgress: progress];}); - Valentine