-1

Is it possible to use MTKTextureLoader.newTextureWithContentsOfURL to retrieve an image from the web (e.g. https://i.stack.imgur.com/EwPfY.jpg?s=48&g=1)? I tried but I didn't succeed, so maybe I did something wrong.

user16217248
  • 3,119
  • 19
  • 19
  • 37
zeus
  • 12,173
  • 9
  • 63
  • 184

1 Answers1

0

The -newTextureWithContentsOfURL:... methods are intended for use with file URLs, not Web URLS.

If you want to load an image from the Internet, you should use NSURLSession and NSURLDataTask to download the image contents first (asynchronously), and then use MTKTextureLoader's -newTextureWithData:options:error: method or its asynchronous counterpart to create a MTLTexture.

warrenm
  • 31,094
  • 6
  • 92
  • 116