From e137c508eecd06674cb557dcd23e9c2fc8a3adc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 3 Jul 2015 19:17:09 +0200 Subject: [PATCH] README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5013e8e6b..d79e2b72c 100644 --- a/README.md +++ b/README.md @@ -119,9 +119,10 @@ let rows = dbQueue.inDatabase { db in **A row sequence is lazy**. It iterates SQLite results as it is consumed. -You will get a *fatal error* if you iterate such a sequence out of the database queue: +If you iterate such a sequence out of a database queue, you will get a *fatal error*: ```swift +// Wrong: sequence is extracted out of the database queue let rowSequence = dbQueue.inDatabase { db in db.fetchRows("SELECT ...") } @@ -132,9 +133,10 @@ for row in rowSequence { } ``` -Avoid those errors by extracting arrays, not sequences: +The solution is to dump such a sequence into an array: ```swift +// Good: extract an array out of the database queue let rows = dbQueue.inDatabase { db in // The `fetchAllRows` variant returns an array of rows: return db.fetchAllRows("SELECT ...")