Доступ к значению из массива SQLite.swift

Как получить строку типа 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!
}

person Craig Jarman    schedule 01.02.2017    source источник


Ответы (1)


Решено - необходимо вернуть Array<SQLite.Row>, а не <Any>.

person Craig Jarman    schedule 06.02.2017