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){ } }); }
UIActivityIndicatorViewnot like? - Max Mikheyenko