如果没有更多的上下文,表达的类型是不明确的

时间:2015-10-06 04:53:17

标签: ios swift xcode7

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。现在我遇到了很多错误。此代码显示错误:

  

如果没有更多的上下文,表达的类型是不明确的

代替withArgs:[]

此处的executeChange方法签名:

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

1 个答案:

答案 0 :(得分:2)

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.