SQLite.swift (Branch Swift-1-2)我在 XCode 6.3 beta 的应用程序中使用。我能够创建数据库/表并将条目插入表中。
到目前为止,一切都很好。
现在,当我有一个简单的场景如下:
class Foo {
var id: Int?
var name: String?
/* constructor to create an instance ... */
}
// This is how the table column is defined
var id = Expression<Int64>("id")
// Function to update data in the table
func updateFoo(foo: Foo) -> Int? {
// 'foos' is the table name
let candidateFoo = foos.filter(super.id == foo.id!) //<----ERROR!!!
let (rowsUpdated, statement) = candidateFoo.update(name <- foo.name!)
if let rowsUpdated = rowsUpdated …Run Code Online (Sandbox Code Playgroud) 当我尝试将job?.id(一个Int64)作为Int参数传递时(虽然我知道它不是那么大),但迅速的编译器提示此错误,我尝试了几种方法进行转换,但未成功:
Cannot convert value of type 'Int64?' to expected argument type 'Int'
Run Code Online (Sandbox Code Playgroud)
我的代码:
Job.updateJobStatus(token: tok, jobId: job?.id, status:JobSatus.canceled) { (result, error) in
if result != nil
{
}
else if error != nil
{
}
}
Run Code Online (Sandbox Code Playgroud)