没有更多上下文,表达式类型不明确
Type of expression is ambiguous without more context
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?
因为withArgs
方法参数定义为
withArgs: [AnyObject]
你不能在那个数组中有 Optionals
。要让它工作,你必须先打开它们。
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?
因为withArgs
方法参数定义为
withArgs: [AnyObject]
你不能在那个数组中有 Optionals
。要让它工作,你必须先打开它们。