I have an app that\'s using background downloads with the new NSURLSession APIs. When a download cancels or fails in such a way that NSURLSessionDownloadT
I have not found an answer to how to tell if the data is valid ahead of time.
However, I am presently working around the issue like so:
NSData *resumeData = ...;
NSURLRequest *originalURLRequest = ...;
NSURLSessionDownloadTask *downloadTask = nil;
@try {
downloadTask = [session downloadTaskWithResumeData:resumeData];
}
@catch (NSException *exception) {
if ([NSInvalidArgumentException isEqualToString:exception.name]) {
downloadTask = [session downloadTaskWithRequest:originalURLRequest];
} else {
@throw exception; // only swallow NSInvalidArgumentException for resumeData
}
}