Skip to content

Commit

Permalink
Fix code sample in framework discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmryan committed Aug 2, 2015
1 parent 09a6985 commit 972db9c
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -363,33 +363,32 @@ FOUNDATION_EXPORT const unsigned char FMDBVersionString[];

8. You can now use this new FMDB framework from your main target. For example, in Swift:

```import UIKit
import FMDB
import UIKit
import FMDB

class ViewController: UIViewController {
class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
override func viewDidLoad() {
super.viewDidLoad()

let documents = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first as! String
let path = documents.stringByAppendingPathComponent("test.sqlite")
NSFileManager.defaultManager().removeItemAtPath(path, error: nil)
let documents = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first as! String
let path = documents.stringByAppendingPathComponent("test.sqlite")
NSFileManager.defaultManager().removeItemAtPath(path, error: nil)

let queue = FMDatabaseQueue(path: path)
let queue = FMDatabaseQueue(path: path)

queue.inDatabase { db in
db.executeUpdate("create table foo (bar text)", withArgumentsInArray: nil)
db.executeUpdate("insert into foo (bar) values (?)", withArgumentsInArray: ["baz"])
queue.inDatabase { db in
db.executeUpdate("create table foo (bar text)", withArgumentsInArray: nil)
db.executeUpdate("insert into foo (bar) values (?)", withArgumentsInArray: ["baz"])

if let rs = db.executeQuery("select * from foo", withArgumentsInArray: nil) {
while rs.next() {
println(rs.resultDictionary())
if let rs = db.executeQuery("select * from foo", withArgumentsInArray: nil) {
while rs.next() {
println(rs.resultDictionary())
}
}
}
}
}
}
}
```


## History
Expand Down

0 comments on commit 972db9c

Please sign in to comment.