Blob.init(dataNoCopy:)

This commit is contained in:
Gwendal Roué committed 2015-09-06 17:39:54 +02:00
1 parent b686e1fe91
commit 236aff297e
2 files changed
+32 -5

No files matched your search

+31 -4
View File
@@ -22,11 +22,38 @@ extension NSData : DatabaseValueConvertible {
}
}
/// Blob support for NSData
extension Blob {
/// Creates a Blob from NSData. Returns nil if and only if *data* is nil or
/// zero-length (SQLite can't store empty blobs).
/**
Creates a Blob from NSData.
Returns nil if and only if *data* is nil or zero-length (SQLite can't store
empty blobs).
The data is *copied*.
- parameter data: An NSData
*/
public init?(data: NSData?) {
// SQLite can't store empty blobs
if let data = data where data.length > 0 {
impl = NSDataImpl(data: data.copy() as! NSData)
} else {
return nil
}
}
/**
Creates a Blob from NSData.
Returns nil if and only if *data* is nil or zero-length (SQLite can't store
empty blobs).
The data is *not copied*.
- parameter data: An NSData
*/
public init?(dataNoCopy data: NSData?) {
if let data = data where data.length > 0 {
impl = NSDataImpl(data: data)
} else {
@@ -45,7 +72,7 @@ extension Blob {
}
}
/// A BlobImpl that stores NSData
/// A BlobImpl that stores NSData without copying it.
private struct NSDataImpl : BlobImpl {
let data: NSData
+1 -1
View File
@@ -16,7 +16,7 @@ Release Notes
- `DatabaseDate` has been removed.
- `DatabaseValueConvertible`: `init?(databaseValue:)` has been replaced by `static func fromDatabaseValue(_) -> Self?`
- `Blob.init(_)` has been renamed `Blob.init(data:)`
- `Blob.init(_)` has been replaced with `Blob.init(data:)` and `Blob.init(dataNoCopy:)`.
- `RowModel.edited` has been renamed `RowModel.databaseEdited`.
- `RowModel.databaseTable` has been replaced with `RowModel.databaseTableName()` which returns a String.
- `RowModel.setDatabaseValue(_:forColumn:)` has been removed. Use and override `RowModel.updateFromRow(_)` instead.