I’ve a set of pictures that I’ve added to the “cat-images” tag underneath Useful resource Tags in Xcode. In testing, I’ve finished this:
let resourceRequest = NSBundleResourceRequest(tags: Set(["cat-images"]))
resourceRequest.conditionallyBeginAccessingResources { (resourcesAvailable) in
if resourcesAvailable {
completion(nil)
} else {
resourceRequest.beginAccessingResources { (error) in
completion(error)
}
}
}
This completes efficiently, however then after I strive do show one of many pictures from that set:
UIImage(named: "siamese.png").map { Picture(uiImage: $0) }
The picture can’t be discovered. Do I must entry the picture another way if it is a part of ODR? Does each single picture within the folder must have its personal tag? Proper now they’re all tagged with “cat-images” however they do not have distinctive ODR tags.
I’ve additionally tried loading the picture like this:
extension Picture {
static func loadFromODR(resourceName: String) -> Picture? {
let parts = resourceName.cut up(separator: ".")
let identify = String(parts[0])
let ext = String(parts[1])
print("trying odr picture: (identify).(ext)")
guard let path = Bundle.major.path(forResource: identify, ofType: ext),
let picture = UIImage(contentsOfFile: path) else {
print("couldn't discover: (identify).(ext)")
return nil
}
return Picture(uiImage: picture)
}
}
however the picture can’t be discovered.