2015-10-06 47 views
2
if personal_id == nil { 

     if let err = SD.executeChange("INSERT INTO personal_info(user_id, fname, lname, gender, dob, country_code, phone, created_at) values (?,?,?,?,?,?,?,?)", withArgs: [email, fname, lname, gender, date, country_code, phone, strDate]) { 
       let alert = UIAlertView() 
       alert.title = "Table" 
       alert.message = "Error inserting" 
       alert.addButtonWithTitle("Ok") 
       alert.show() 
     } else{ 
      let alert = UIAlertView() 
      alert.title = "Table" 
      alert.message = "successfully inserted" 
      alert.addButtonWithTitle("Ok") 
      alert.show() 
     } 
    } else { 
     if let err_update = SD.executeChange("UPDATE personal_info SET fname = ?, lname = ?, gender = ?, dob = ?, country_code = ?, phone = ?, updated_at = ? WHERE personal_info_id = ?", withArgs: [fname, lname, gender, date, country_code, phone, strDate, personal_id!]) { 
       let alert = UIAlertView() 
       alert.title = "Table" 
       alert.message = "Error updating" 
       alert.addButtonWithTitle("Ok") 
       alert.show() 
     } else { 
       let alert = UIAlertView() 
       alert.title = "Table" 
       alert.message = "Record updated" 
       alert.addButtonWithTitle("Ok") 
       alert.show() 
     } 
    } 

我最近已經從6.4更新到Xcode 7.0.1。現在我有很多錯誤。此代碼顯示一個錯誤:表達式的類型是不明確的,沒有更多的上下文

Type of expression is ambiguous without more context

withArgs的地方:[]

這裏的executeChange方法簽名:

public static func executeChange(sqlStr: String, withArgs: [AnyObject]) -> Int? 
+1

「executeChange」調用的函數參數是什麼?什麼是電子郵件,fname,lname,性別,日期,country_code,電話和strDate的類型? –

+0

withArgs []是anyObject類型,其餘名稱,名稱,性別,日期等是字符串 –

+0

我正在使用swift數據框架 –

回答

2

由於withArgs方法參數定義爲

withArgs: [AnyObject] 

你不能有該數組中的。爲了使它工作,你必須先解開它們。

+0

感謝兄弟..工作! –

相關問題