【发布时间】:2021-02-25 18:38:39
【问题描述】:
谁能帮我解决这个问题?我是 Swift 和 sqlite 的新手。
我将这个字符串传递给一个函数
let compositionstring = "iris, magenta, iris";
我将它转换为数组的地方
let compositionArr = string.components(separatedBy: ",")
然后我期待下面的代码查询数据库并打印组合字符串中每个的路径、文件名和类别。
do {
try compositionArr.forEach {
print($0)
for var files in try db.prepare(files.select(path, name, category).filter(category.like($0)).limit(1)) {
print("path: \(files[path]), filename: \(files[name]), category: \(files[category])")
}
}
但我只得到第一个结果,之后什么都没有。
虹膜
路径:文件://localhost/Volumes/IWL%20Jen%20Vid/IWL%20Captions/Material_Sonia/Sonia%202019/IWL%20videos/Mexico/Palacio%20belle%20arte/IMG_7762.MOV,文件名:IMG_7762.MOV , 类别:鸢尾花
洋红色
虹膜
我必须缺少一些非常基本的东西。感谢您的帮助!
【问题讨论】: