如何使用行号来获取SQLite.Row类型的行?
这是使用结果数组填充选择器的顺序。
由于
var allCountries:Array<Any>?
let countries = Table("Country")
let id = Expression<Int64>("rowid")
let name = Expression<String>("Name")
let code = Expression<String>("Code")
func pickerView(_ pickerView:UIPickerView, titleForRow row: Int, forComponent component:Int) -> String?{
return allCountries?[row].*somethingHere* as String
//The array is populated with rows of type SQLite.Row
}
func getCountries() -> Array<Any>{
var results:Array<Any>?
do{
let path = Bundle.main.path(forResource: "location", ofType: "sqlite")
let db = try Connection(path!, readonly: true)
results = Array(try db.prepare(countries))
}
catch{
print("Error")
}
return results!
}
答案 0 :(得分:0)
已解决 - 需要返回refresh
,而不是Array<SQLite.Row>
。