Gentlemen, who is well versed in the swift language? I need to access one or more files in the Assets.xcassets folder from the program. How can this be done and is it possible in principle?

  • What do you mean and what do you want to do? - VAndrJ
  • @VAndrJ I need to read the file in the bundle, or in Assets.xcassets - Pretzel

1 answer 1

func readBundle(file:String) -> String { var res = "" if let asset = NSDataAsset(name: file) , string = String(data:asset.data, encoding: NSUTF8StringEncoding) { res = string } return res } 

The answer is taken here .