FMDB,Swift 3,executeUpdate - 编译器构建失败

时间:2016-10-16 11:40:46

标签: compilation swift3 fmdb

我使用FMDB和Swift 3。 在Swift 2上一切正常,但在进行Swift升级之后,我得到了: "命令因信号失败:被杀:9"

在调查其原因后,我发现正在执行" executeUpdate"在ArgumentsArray中有大约24个参数会导致编译器非常慢并最终返回编译错误。

当将数组中的参数数量减少到20时,编译器构建仍然很慢但成功完成。

任何想法为什么/帮助都会受到欢迎......!

这是我的代码: (构建成功但是取消注释下面的4行会使编译构建失败。当然,任何其他4行都会有相同的结果)

func insertLocalization(_ localization: Localization) -> Bool {
        print ("Insert Localization: \(localization.localization_object_id!)#\(localization.spot_object_id!)#\(localization.language_code!)")
        sharedInstance.database!.open()
        let isInserted = sharedInstance.database!.executeUpdate(
            "INSERT INTO localizations (" +
                "localization_object_id, " +
                "spot_object_id, " +
                "language_code, " +
                "current_location_enabled, " +
                "spot_title, " +
                "spot_desc, " +
                "local_assistant_phone, " +
                "orientation_360_enabled, " +
                "direction_n_title, " +
                "direction_n_desc, " +
                "direction_ne_title, " +
                "direction_ne_desc, " +
                "direction_e_title, " +
                "direction_e_desc," +
                "direction_se_title, " +
                "direction_se_desc, " +
                "direction_s_title, " +
                "direction_s_desc, " +
                "direction_sw_title, " +
                "direction_sw_desc, " +
                "direction_w_title, " +
                "direction_w_desc, " +
                "direction_nw_title, " +
                "direction_nw_desc) " +
            "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
            withArgumentsIn: [
                // localization.localization_object_id!,
                // localization.spot_object_id!,
                // localization.language_code!,
                // localization.current_location_enabled!,
                localization.spot_title!,
                localization.spot_desc!,
                localization.local_assistant_phone!,
                localization.orientation_360_enabled!,
                localization.direction_n_title!,
                localization.direction_n_desc!,
                localization.direction_ne_title!,
                localization.direction_ne_desc!,
                localization.direction_e_title!,
                localization.direction_e_desc!,
                localization.direction_se_title!,
                localization.direction_se_desc!,
                localization.direction_s_title!,
                localization.direction_s_desc!,
                localization.direction_sw_title!,
                localization.direction_sw_desc!,
                localization.direction_w_title!,
                localization.direction_w_desc!,
                localization.direction_nw_title!,
                localization.direction_nw_desc!
            ])
        sharedInstance.database!.close()
        return isInserted
    }

谢谢!

1 个答案:

答案 0 :(得分:0)

此代码在Xcode 8.0(8A218a)中编译时没有任何意外。但如果这对你不起作用,我建议拆分该行,例如

let values =  [localization.localization_object_id!, ..., localization.direction_nw_desc!]

let isInserted = sharedInstance.database!.executeUpdate(
    "INSERT INTO localizations (...) " +
    "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
    withArgumentsIn: values)