Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UIImage's imageLiteralResourceName: initializer #10941

Open
iamgabrielma opened this issue Oct 13, 2023 · 4 comments · May be fixed by #10973
Open

Update UIImage's imageLiteralResourceName: initializer #10941

iamgabrielma opened this issue Oct 13, 2023 · 4 comments · May be fixed by #10973
Assignees
Labels
good first issue The issue is a good candidate for a community contribution or for a newcomer to the team. type: enhancement A request for an enhancement.

Comments

@iamgabrielma
Copy link
Contributor

iamgabrielma commented Oct 13, 2023

We have several places where we initialize images using UIImage(imageLiteralResourceName: String) initializer. This could be an issue since relies on a String literal and it's implementation shows that would crash if the resource cannot be found:

extension UIImage {

    /// Creates an instance initialized with the given resource name.
    ///
    /// Do not call this initializer directly. Instead, initialize a variable or
    /// constant using an image literal.
    required public convenience init(imageLiteralResourceName name: String)
}

Instead we should use UIImage(named: String) which would return nil instead.

@iamgabrielma iamgabrielma added type: enhancement A request for an enhancement. good first issue The issue is a good candidate for a community contribution or for a newcomer to the team. labels Oct 13, 2023
@peril-woocommerce
Copy link

Fails
🚫 Please add a feature label to this issue. e.g. 'feature: stats'

Generated by 🚫 dangerJS

@ashwinpra
Copy link

I'd like to work on this issue, please assign this to me :)

@ashwinpra
Copy link

@iamgabrielma I have created a PR. Please do review it :)

@iamgabrielma
Copy link
Contributor Author

Thanks for contributing @ashwinpra !

Please take a look to the contributing guide here in order to submit the PR with all necessary information for the reviewer to understand the context of the changes, which testing steps are required, etc, ... upon opening a new PR you should see a pre-made template to help with that.

Let me know if you have any question 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue The issue is a good candidate for a community contribution or for a newcomer to the team. type: enhancement A request for an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants