Check if string name matches asset in images.xcassets

Everything I do google calls up answers to the question about ALAsset.

I have an images.xcassets folder and a bunch of assets.

I want to know if an asset exists there depending on the string.

eg. if(images.xcassets.contains("assetName") == true)

Do you know how I can check if a row based resource exists?

+6
source share
3 answers

This is one way to verify this.

 NSString *someString = @"SomeStringFromSomwhere"; if ([UIImage imageNamed: someString]) { //the image exists.. } else { //no image with that name } 
+7
source

Check if image exists or not: Swift 3

 if (UIImage(named: "your_Image_name") != nil) { print("Image existing") } else { print("Image is not existing") } 
+4
source

Somewhat more practical answer: Swift

 if let myImage = UIImage(named: "assetName") { // use your image (myImage), it exists! } 
+2
source

Source: https://habr.com/ru/post/983129/


All Articles