mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
21 lines
591 B
Swift
21 lines
591 B
Swift
#if !os(Linux)
|
|
import Foundation
|
|
|
|
/// NSString adopts DatabaseValueConvertible
|
|
extension NSString: DatabaseValueConvertible {
|
|
|
|
/// Returns a value that can be stored in the database.
|
|
public var databaseValue: DatabaseValue {
|
|
(self as String).databaseValue
|
|
}
|
|
|
|
/// Returns an NSString initialized from *dbValue*, if possible.
|
|
public static func fromDatabaseValue(_ dbValue: DatabaseValue) -> Self? {
|
|
guard let string = String.fromDatabaseValue(dbValue) else {
|
|
return nil
|
|
}
|
|
return self.init(string: string)
|
|
}
|
|
}
|
|
#endif
|