2016-10-16 19 views
0

私はSwift 3でFMDBを使用しています。 Swift 2ではすべてがうまくいきましたが、Swiftアップグレード後には " 9 "FMDB、Swift 3、executeUpdate - コンパイラのビルドに失敗しました

原因を調べたところ、ArgumentsArrayで約24個の引数を持つ" executeUpdate "を実行すると、コンパイラが非常に遅くなり、最終的にコンパイルエラーが返されることがわかりました。

配列の引数の数を20に減らすと、コンパイラのビルドはまだまだ遅くなりますが、正常に終了します。

なぜ/助けが歓迎されるのでしょうか?

はここに私のコードです:

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 
    } 

おかげで(。成功ビルドが、コンパイル、ビルドが失敗したようになります以下の4行をコメントアウトその他の4行はもちろん、同じ結果になります)!

答えて

0

このコードは、私のためにXcode 8.0(8A218a)で無修正でコンパイルされます。これはあなたのために働いていない場合でも、私は私の現在の一時的な解決策は、2つの操作最初 をに分割することでした:( 助けにはならなかった不幸な例

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

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

ため、ラインアップを分割することをお勧めしたいです。 INSERT the – Gilu

+0

残念ながらそれは助けになりませんでした:(私の現在の一時的な解決策は2つの操作にINSERT操作を分割することでした:最初の8列をINSERTした後、最後の16列を挿入したレコードをUPDATEします。私の意見のための解決策。 – Gilu

関連する問題