I cannot access images inside an asset catalog after it's been downloaded through NSBundleResourceRequest (on demand resource).
My code, say the image set name is "snow_4" with on demand resource tag "tag1"
NSBundleResourceRequest* resourceRequest = [[NSBundleResourceRequest alloc] initWithTags:[NSSet setWithObjects:@"tag1", nil]];
[resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:
^(BOOL resourcesAvailable){
// if resource is not available download it
if (!resourcesAvailable) {
[resourceRequest beginAccessingResourcesWithCompletionHandler:
^(NSError * __nullable error){
if(!error){
UIImage* image = [UIImage imageNamed:@"snow_4"]; // image is null
}
}];
}else{
UIImage* image = [UIImage imageNamed:@"snow_4"]; // image is null
}
}];
Below is my Disk Report, please note that [UIImage imageNamed:@"snow_3"] (marked as 'In Use') returns a correct object but not images that are marked as 'Downloaded'
Appreciating your time and help!
Thanks, Mars
do this
image = [UIImage imageNamaed:@"snow_4" inBundle:[resourceRequest bundle]];