Reputation: 1651
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()
}
}
I have recently updated to Xcode 7.0.1 from 6.4. Now I am having a lot of errors. This code shows an error:
Type of expression is ambiguous without more context
in the place of withArgs
: []
Here's executeChange
method signature:
public static func executeChange(sqlStr: String, withArgs: [AnyObject]) -> Int?
Upvotes: 2
Views: 1489
Reputation: 1993
Since withArgs
method parameter defined as
withArgs: [AnyObject]
you can't have Optionals
in that array. To make it work you'll have to unwrap them first.
Upvotes: 2