我最近一直在使用SQLite.swift来构建我的app数据库.我正在INTEGER用Int64类型定义我的所有列,就像文档解释的那样.
但每隔一段时间我就Int64需要这样做Int.所以我的问题是,如果我这样做:
//Create a table with Int instead of Int64
let test_id = Expression<Int>("test_id")
let tests = db["tests"]
db.create(table: tests, ifNotExists: true){ t in
t.column(test_id)
}
class func insertTest(t: Int) -> Int{
//insert.rowid returns an Int64 type
let insert = tests.insert(test_id <- t)
if let rowid = insert.rowid{
//directly cast Int64 into Int
return Int(rowid)
}
return 0
}
Run Code Online (Sandbox Code Playgroud)
这是对的吗?
当然我测试了它.它确实有效,但我正在Stackoverflow中阅读这个问题
似乎我可能遇到32位设备的问题......
如果这是错的,我怎么能Int64投入Int?