我想知道在MySQL的IN子句的Core Data / Swift中是否有任何等效的命令:
"SELECT details FROM tbl_details WHERE ticket IN (1,2,3)
答案 0 :(得分:1)
这应该有效:
let list = [1, 2, 3]
let inPred = NSPredicate(format: "ticket IN %@", list)
var request = NSFetchRequest(entityName: "details")
request.returnsObjectsAsFaults = false
request.predicate = inPred
之后,以通常的方式调用context.executeFetchRequest
来检索结果。