My app allows for downloading a PDF to the device. However, while the PDF is being downloaded, the app is unable to do anything until the download completes. How can I do this so other actions can be handled while download is in progress? This is what I have so far for downloading it.
RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
NSString *urlString = entry.articlePDF;
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filename = [entry.articleTitle stringByAppendingString:@".pdf"];
NSString *removed = [filename stringByReplacingOccurrencesOfString:@"/" withString:@""];
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent: removed];
NSLog(@"Downloadstarted%@", pdfPath);
[data writeToFile:pdfPath atomically:YES];