2017-10-15 30 views
-4

我正在使用api,它为图像返回“uri”(而不是url)。将“uri”存储为本地对象的属性之后,我无法弄清楚如何处理“uri”字符串以将其转换为UIImage。另外,如果能够更清楚地了解url和uri之间的差异,那将是非常好的。将URI(非URL)转换为Swift中的UIImage

This is an example of the response from the server

+0

我会建议添加的响应例如作为代码片段,而不是图像。 –

+0

服务器的URL是什么? – ozgur

+0

这个URL http://data.tmsapi.com/v1.1/movies/showings(一个API密钥是一个必需的参数) – rrozenv

回答

0

试试这个:

let uri = "assets/p12565017_p_v5_ae.jpg" 

// The API documentation will tell you what the base URL is 
let baseURL = URL(string: "https://www.somewhere.com")! 
let imageURL = URL(string: uri, relativeTo: baseURL)!