编译器抱怨他的代码而不确定如何修复:
SELECT
e.examenID, e.contenidoID, e.tituloExamen,
u.userID, u.userEmail,
cu.userID, cu.cursoID, cu.examenes, cu.examenesRendidos,
co.contenidoID, co.tituloContenido,
cc.contenidoID, cc.cursoID,
c.cursoID, c.nombreCurso
FROM examenes ex
JOIN contenidos co
ON ex.contenidoID = co.contenidoID
JOIN cursosContenidos cc
ON co.contenidoID = cc.contenidoID
JOIN cursos c
cc.cursoID = c.cursoID
JOIN cursosUsuarios cu
ON c.cursoID = cu.cursoID
JOIN usuarios u
ON cu.userID = u.userID
WHERE
cu.cursoID = 15
cu.userID = 1
它抱怨它JOIN cursos c
cc.cursoID = c.cursoID
我使用Xcode 7.3.1和Swift 2.2
答案 0 :(得分:3)
NSProcessInfo.processInfo().environment
会返回[String : String]
字典。
要在字典上使用contains
,您必须传递闭包,而不是字符串。
Swift 2的例子:
// This is just to make the answer easier to read
let env = NSProcessInfo.processInfo().environment
测试键是否包含您的字符串:
let result = env.contains { $0.0.containsString("UITESTING") }
或测试相等性,例如:
let result = env.contains { $0.0 == "UITESTING" }
测试值是否包含您的字符串:
let result = env.contains { $0.1.containsString("UITESTING") }
或等于:
let result = env.contains { $0.1 == "UITESTING" }
$0
是字典中的每个项目,.0
是关键字,.1
是值。
为了更好地理解,这里有长格式语法:
let result = env.contains { (key, value) in key.containsString("UITESTING") }
在Swift 3中,万一有人需要它:
let env = ProcessInfo.processInfo.environment
let result = env.contains { $0.key.contains("UITESTING") }
let result = env.contains { $0.value.contains("UITESTING") }
let result = env.contains { (key, value) in key.contains("UITESTING") }