Hi,
I love the idea of the ImageResource struct and it is a great error reduction to automatically provide an ImageResource for every Image in the asset catalog. I immediately started to adopt it.
But I have a case where I would still need to have access to the name of the Image and the bundle. So I would suggest that you provide change the struct for ImageResource to have name and bundle as public getters. With this, there is still a safe way in the code to access the resource and still be able to use the name of the resource.
So instead of generating: struct ImageResource: Hashable {
/// An asset catalog image resource name.
fileprivate let name: String
/// An asset catalog image resource bundle.
fileprivate let bundle: Bundle
/// Initialize an `ImageResource` with `name` and `bundle`.
init(name: String, bundle: Bundle) {
self.name = name
self.bundle = bundle
}
}
Just generate it as: struct ImageResource: Hashable {
/// An asset catalog image resource name.
let name: String
/// An asset catalog image resource bundle.
let bundle: Bundle
/// Initialize an `ImageResource` with `name` and `bundle`.
init(name: String, bundle: Bundle) {
self.name = name
self.bundle = bundle
}
}
The same applies to ColorResource as well.
I have posted a feedback on this, but I am curious what others think about this? Am I the only one who still needs to have access to the name and the bundle of the ressource?