I faced a problem when I was trying to save and retrieve array from SQLite database using FMDB. I'm archiving array of arrays of doubles with NSKeyedArchiver and saving it like that:
let fakeRoute: [[Double]] = [[22.2, 33.3], [44.5, 69.4]]
let fakeRouteData = NSKeyedArchiver.archivedDataWithRootObject(fakeRoute)
db.executeUpdate("insert into \(tableName) values(?);", fakeRouteData)
I can see data in corresponding column, but when I'm retrieving it like that
let routeData = results.dataForColumn(DB.Column.route)
data is different from the one I inserted and I'm unable to unarchive it. However, it can be built into string that contains string representation of data I inserted. The column is of type BLOB, why do I get the string data? How can I get my array back ?
Aucun commentaire:
Enregistrer un commentaire