This question relates to StephenCelis Sqlite library, so if someone has any idea about this, please share your fix. Though I have put my question on the issue tracker but haven't received any response yet, so I am also posting it here.
This is the function for creating DB record, which works fine.
public func createCandy(candy: Candy) throws
{
self.loadDb()
let db = try self.getDB()
let statement = try db.prepare("Insert INTO Candy(category, name, image, imageData) VALUES(?, ?, ?, ?)")
try statement.run(candy.category, candy.name, candy.image, candy.impageData.datatypeValue)
}
However, while retrieving data from Sqlite, I get the issue in the line candy.impageData = row[4] as? Data.
Following is the code for reading data
let candy = Candy()
candy.Id = row[0] as! Int64
candy.category = row[1] as? String
candy.name = row[2] as? String
candy.image = row[3] as? String
candy.impageData = row[4] as? Data
candies.append(candy)
This is the error message:
Could not cast value of type 'SQLite.Blob' to 'Swift.Data'
Just wondering what is the appropriate class in the library for casting this.