I want to save data unfinished downloads when the app is closed.
Tried so, but always empty resumeData:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate) name:UIApplicationWillTerminateNotification object:nil];
- (void)appWillTerminate
{
[self.downloadTask cancelByProducingResumeData:^(NSData *resumeData) {
if (resumeData)
[self saveData:resumeData];
else
NSLog(@"Not exist");
}];
}
In my experience, downloading small files does not create resumeData
. Try with a larger file (> 20 mb).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With