From 63a6ef021a417a3e1beb7ba4a20ddb7a6babeab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 3 Mar 2016 14:33:21 +0100 Subject: [PATCH] FAQ: How do I open a database stored as a resource of my application? --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bcc4af7ce..87769e6c3 100644 --- a/README.md +++ b/README.md @@ -2372,10 +2372,10 @@ FAQ If your application does not need to modify the database, then open a [database queue](#database-queues) to your resource, making sure the connection is read-only: ```swift - let dbURL = NSBundle.mainBundle().URLForResource("db", withExtension: "sqlite") var configuration = Configuration() configuration.readonly = true - let dbQueue = DatabaseQueue(dbURL.path, configuration: configuration) + let dbPath = NSBundle.mainBundle().URLForResource("db", withExtension: "sqlite")!.path! + let dbQueue = DatabaseQueue(path: dbPath, configuration: configuration) ``` If the application should modify the database, then you need to copy it to a place where it can be modified. For example, in the Documents folder: