Last active
October 8, 2015 06:45
-
-
Save gobozgz/9d1b02364f878bc1a026 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SQLite | |
class AreaInfoViewController: UIViewController { | |
@IBOutlet weak var webView: UIWebView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
getAreaPdf(7) | |
} | |
func getAreaPdf (areaId: Int64) ->NSData { | |
var myPdf:NSData | |
let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true) | |
let docsDir = dirPaths[0] | |
let databasePath = docsDir.stringByAppendingString("/database.sqlite") | |
let path = InitDb() | |
let db = try! Connection(path, 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 == areaId) | |
.limit(1) | |
let result = db.prepare(query) | |
for row in result { | |
print (row[pdffile]) //At this point row[pdffile] is Blob type | |
} | |
return myPdf; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment