I drag a image.jpg into the assets.xcassets.
Then you have added an Image Set of name image to the Asset catalogue, not Data Set.
You may need to use UIImage.init(named:).
Or else if you want to use NSDataAsset, you need to add a Data Set
It works for me. I make a new data set, and drag the image into it. Thanks a lot. The only flaw is that it would not to provide "1x、2x、3x" options for resources like image set. :(
BTW, is "UIImage(named:)" the only way to retrieve image data from image set in assets catalog? Are there other feasible methods, like by url, Data-like object, or ...? UIImage is a bit expensive for sizing and to resizing.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: