From 1c7c2536ca1bdaba8c75b26a6770b72a651c8a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sat, 26 Sep 2015 18:57:19 +0200 Subject: [PATCH] DatabaseValue.dataNoCopy documentation --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 475e518a4..a6ae10911 100644 --- a/README.md +++ b/README.md @@ -414,11 +414,16 @@ Custom value types are supported as well through the [DatabaseValueConvertible]( **NSData** suits the BLOB SQLite columns. It can be stored and fetched from the database just like other value types. -Yet, when extracting NSData from a row, you have an extra option: +Yet, when extracting NSData from a row, **you have the opportunity to save memory by not copying the database data**: ```swift -let copiedData: NSData? = row.value(named: "data") // Like other value types -let notCopiedData: NSData? = row.dataNoCopy(named: "data") // Specific to NSData +// When the "data" column is know to be there: +let notCopiedData: NSData? = row.dataNoCopy(named: "data") + +// Test if the column `data` is present: +if let databaseValue = row["data"] { + let notCopiedData: NSData? = databaseValue.dataNoCopy +} ``` Make sure that you do not use the non-copied data longer than the row's lifetime.