最佳答案
我觉得这比什么都有趣。我已经修好了,但我想知道原因。这里有一个错误: DataManager.swift:51:90: Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
。它为什么要抱怨?这似乎是最简单的表达方式之一。
编译器指向 columns + ");";
节
func tableName() -> String { return("users"); }
func createTableStatement(schema: [String]) -> String {
var schema = schema;
schema.append("id string");
schema.append("created integer");
schema.append("updated integer");
schema.append("model blob");
var columns: String = ",".join(schema);
var statement = "create table if not exists " + self.tableName() + "(" + columns + ");";
return(statement);
}
解决办法是:
var statement = "create table if not exists " + self.tableName();
statement += "(" + columns + ");";
这也可以(通过@efischency) ,但我不太喜欢它,因为我认为 (
会迷路:
var statement = "create table if not exists \(self.tableName()) (\(columns))"