mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
Document throwing row accessors
This commit is contained in:
1 parent
b572982e34
commit
a46f3b69e9
1 file changed
+7
@@ -843,6 +843,13 @@ row[...] as Int
|
||||
row[...] as Int?
|
||||
```
|
||||
|
||||
Throwing accessors exist as well. Their use is not encouraged, because a database decoding error is a programming error. If an application stores invalid data in the database file, that is a bug that needs to be fixed:
|
||||
|
||||
```swift
|
||||
let name = try row.decode(String.self, atIndex: 0)
|
||||
let bookCount = try row.decode(Int.self, forColumn: "bookCount")
|
||||
```
|
||||
|
||||
> **Warning**: avoid the `as!` and `as?` operators:
|
||||
>
|
||||
> ```swift
|
||||
|
||||
Reference in new issue
Block a user