Im trying to get a NSData object from a Blob to load it into a Web View. I've read the documentation about SQLite.swift but I've nothing clear. Please, help me. I think I need a working example.
my code: http://ift.tt/1LmQyLt
import UIKit
import SQLite
class AreaInfoViewController: UIViewController {
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Here I Will load the webView PDFFile into the webView
// webView.loadRequest(getAreaPdf())
}
func getAreaPdf () -> NSDATA {
var myPdf:NSDATA // I think this is wrong
let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let docsDir = dirPaths[0]
let databasePath = docsDir.stringByAppendingString("/db.sqlite")
let db = try! Connection(databasePath, readonly: true)
let areas = Table("areas")
let id = Expression<Int64>("id")
let name = Expression<String>("name")
let pdffile = Expression<SQLite.Blob>("pdffile")
let query = areas.select(id,name,pdffile)
.filter(id == 1)
.limit(1)
let result = db.prepare(query)
for row in result {
myPdf = row[pdffile] // Obviusly this is wrong
}
return myPdf // Obviusly this is wrong too
}
}
Thanks a lot everyone.
Greetings, David
Aucun commentaire:
Enregistrer un commentaire