[英]Extract data from Algorithmia response
I am currently making an app that sends data to an Algorithmia algorithm where it is processed.我目前正在制作一个应用程序,将数据发送到处理它的 Algorithmia 算法。 A response of where to find the file is then sent back to the app in this form:
然后以这种形式将有关在何处查找文件的响应发送回应用程序:
Optional({
output = "data://.algo/deeplearning/AlgorithmName/temp/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png";})
I need a way to extract the randomly generated 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png' section of the response.我需要一种方法来提取响应的随机生成的 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.png' 部分。 It needs to be stored in a string which I will use later.
它需要存储在我稍后将使用的字符串中。
Final code:最终代码:
if let json = response as? [String: Any] {
print(json)
let filePath = json["output"] as? String
print("File path: \(filePath!)")
let uwFilePath = filePath!
let index = uwFilePath.index(uwFilePath.startIndex, offsetBy: 57)
self.imageFileName = uwFilePath.substring(from: index)
print(self.imageFileName)
}
imageFileName is storing the final file name for later use. imageFileName 正在存储最终文件名以供以后使用。 The begining part of the output string is also being cut off.
输出字符串的开始部分也被截断了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.