I have a SqLite database. I use FMDB. How to select and show all the rows of the database selected?. In this code I can show just the first name, the first row. But how to iterate through all the rows selected and show them with Swift?
@IBAction func selectNoms(sender: AnyObject) {
let contactDB = FMDatabase(path: databasePath as String)
if contactDB.open() {
let querySQL = "SELECT name FROM CONTACTS"
let results:FMResultSet? = contactDB.executeQuery(querySQL,
withArgumentsInArray: nil)
if results?.next() == true {
status.text = results?.stringForColumn("name")
}
contactDB.close()
} else {
println("Error: \(contactDB.lastErrorMessage())")
}
}
Aucun commentaire:
Enregistrer un commentaire