iOS will purge assets after being downloaded as soon as it needs to free up some space.
Changing the preservation priorities of the assets will not prevent the system from purging them as stated in the "Setting Preservation Priority" section here.
My relevant code to download the On-demand resources is the following:
func requestResourceWith(tag: [String],
onSuccess: @escaping () -> Void,
onFailure: @escaping (NSError) -> Void) {
currentRequest = NSBundleResourceRequest(tags: Set(tag))
guard let request = currentRequest else { return }
request.endAccessingResources()
request.loadingPriority =
NSBundleResourceRequestLoadingPriorityUrgent
request.beginAccessingResources { (error: Error?) in
if let error = error {
onFailure(error as NSError)
return
}
onSuccess()
}
}
After downloading the On-Demand resources, they can be accessed from the main bundle.
Is there anyway to make audios persist, and hence prevent the system from purging them?